yavsc/web/Controllers/WorkFlowController.cs

108 lines
2.2 KiB
C#

10 years ago
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Http;
using WorkFlowProvider;
10 years ago
using Yavsc.Model.WorkFlow;
using System.Web.Http.Controllers;
using System.Web.Security;
10 years ago
namespace Yavsc.ApiControllers
{
[HttpControllerConfiguration(ActionValueBinder=typeof(Basic.MvcActionValueBinder))]
10 years ago
public class WorkFlowController : ApiController
{
string adminRoleName="Admin";
protected override void Initialize (HttpControllerContext controllerContext)
{
10 years ago
// TODO move it in a module initialization
base.Initialize (controllerContext);
if (!Roles.RoleExists (adminRoleName)) {
Roles.CreateRole (adminRoleName);
}
}
[HttpGet]
[Authorize]
public long CreateEstimate (string title)
{
10 years ago
return WorkFlowManager.CreateEstimate (
Membership.GetUser().UserName,title);
}
[HttpGet]
[Authorize]
public void DropWritting(long wrid)
{
10 years ago
WorkFlowManager.DropWritting (wrid);
}
[HttpGet]
[Authorize]
public void UpdateWritting(Writting wr)
{
10 years ago
WorkFlowManager.UpdateWritting (wr);
}
[HttpGet]
[Authorize]
public void DropEstimate(long estid)
{
10 years ago
WorkFlowManager.DropEstimate (estid);
}
10 years ago
[HttpGet]
[Authorize]
10 years ago
public object Index()
{
// TODO inform user on its roles and alerts
string username = Membership.GetUser ().UserName;
return new { test=string.Format("Hello {0}!",username) };
10 years ago
}
10 years ago
[HttpGet]
[Authorize]
public long Write (long estid, string desc, decimal ucost, int count, long productid=0) {
// TODO ensure estid owner matches the current one
10 years ago
return WorkFlowManager.Write(estid, desc, ucost, count, productid);
}
/*
10 years ago
public object Details(int id)
{
throw new NotImplementedException ();
}
public object Create()
{
throw new NotImplementedException ();
}
10 years ago
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;
}
}
*/
10 years ago
}
}