yavsc/web/Controllers/WorkFlowController.cs

107 lines
2.2 KiB
C#
Raw Normal View History

2014-07-16 20:35:03 +02:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Http;
using WorkFlowProvider;
2014-10-06 04:58:47 +02:00
using Yavsc.Model.WorkFlow;
using System.Web.Http.Controllers;
using System.Web.Security;
2014-07-16 20:35:03 +02:00
namespace Yavsc.ApiControllers
{
[HttpControllerConfiguration(ActionValueBinder=typeof(Basic.MvcActionValueBinder))]
2014-07-16 20:35:03 +02:00
public class WorkFlowController : ApiController
{
string adminRoleName="Admin";
protected override void Initialize (HttpControllerContext controllerContext)
{
2014-10-06 04:58:47 +02:00
// TODO move it in a module initialization
base.Initialize (controllerContext);
if (!Roles.RoleExists (adminRoleName)) {
Roles.CreateRole (adminRoleName);
}
}
[HttpGet]
[Authorize]
public long CreateEstimate (string title)
{
return WFManager.CreateEstimate (
Membership.GetUser().UserName,title);
}
[HttpGet]
[Authorize]
public void DropWritting(long wrid)
{
WFManager.DropWritting (wrid);
}
2014-09-25 12:42:43 +02:00
[HttpGet]
[Authorize]
public void UpdateWritting(Writting wr)
{
WFManager.UpdateWritting (wr);
}
[HttpGet]
[Authorize]
public void DropEstimate(long estid)
{
WFManager.DropEstimate (estid);
}
2014-07-16 20:35:03 +02:00
[HttpGet]
[Authorize]
2014-07-16 20:35:03 +02:00
public object Index()
{
// TODO inform user on its roles and alerts
string username = Membership.GetUser ().UserName;
return new { test=string.Format("Hello {0}!",username) };
2014-07-16 20:35:03 +02:00
}
2014-07-16 20:35:03 +02:00
[HttpGet]
[Authorize]
public long Write (long estid, string desc, decimal ucost, int count, long productid=0) {
// TODO ensure estid owner matches the current one
return WFManager.Write(estid, desc, ucost, count, productid);
}
/*
2014-07-16 20:35:03 +02:00
public object Details(int id)
{
throw new NotImplementedException ();
}
public object Create()
{
throw new NotImplementedException ();
}
2014-07-16 20:35:03 +02:00
public object Edit(int id)
{
throw new NotImplementedException ();
}
public object Delete(int id)
{
throw new NotImplementedException ();
}
IContentProvider contentProvider = null;
IContentProvider ContentProvider {
get {
if (contentProvider == null )
contentProvider = WFManager.GetContentProviderFWC ();
return contentProvider;
}
}
*/
2014-07-16 20:35:03 +02:00
}
}