yavsc/web/Controllers/WorkFlowController.cs

73 lines
1.7 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)
{
2014-10-08 10:47:40 +02:00
return WorkFlowManager.CreateEstimate (
Membership.GetUser().UserName,title);
}
[HttpGet]
[Authorize]
public void DropWritting(long wrid)
{
2014-10-08 10:47:40 +02:00
WorkFlowManager.DropWritting (wrid);
}
2014-09-25 12:42:43 +02:00
[HttpGet]
[Authorize]
public void UpdateWritting(Writting wr)
{
2014-10-08 10:47:40 +02:00
WorkFlowManager.UpdateWritting (wr);
2014-09-25 12:42:43 +02:00
}
[HttpGet]
[Authorize]
public void DropEstimate(long estid)
{
2014-10-08 10:47:40 +02:00
WorkFlowManager.DropEstimate (estid);
}
2014-10-12 15:22:45 +02:00
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
}
[HttpGet]
[HttpPost]
[Authorize]
public long Write (long estid, string desc, decimal ucost, int count, string productid) {
// TODO ensure estid owner matches the current one
2014-10-08 10:47:40 +02:00
return WorkFlowManager.Write(estid, desc, ucost, count, productid);
}
2014-07-16 20:35:03 +02:00
}
}