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;
|
2014-07-24 05:04:56 +02:00
|
|
|
|
using System.Web.Http.Controllers;
|
2014-09-23 12:25:41 +02:00
|
|
|
|
using System.Web.Security;
|
2014-07-16 20:35:03 +02:00
|
|
|
|
|
|
|
|
|
|
namespace Yavsc.ApiControllers
|
|
|
|
|
|
{
|
2014-07-24 05:04:56 +02:00
|
|
|
|
[HttpControllerConfiguration(ActionValueBinder=typeof(Basic.MvcActionValueBinder))]
|
2014-07-16 20:35:03 +02:00
|
|
|
|
public class WorkFlowController : ApiController
|
|
|
|
|
|
{
|
2014-10-06 03:05:57 +02:00
|
|
|
|
string adminRoleName="Admin";
|
|
|
|
|
|
|
|
|
|
|
|
protected override void Initialize (HttpControllerContext controllerContext)
|
|
|
|
|
|
{
|
2014-10-06 04:58:47 +02:00
|
|
|
|
// TODO move it in a module initialization
|
2014-10-06 03:05:57 +02:00
|
|
|
|
base.Initialize (controllerContext);
|
|
|
|
|
|
if (!Roles.RoleExists (adminRoleName)) {
|
|
|
|
|
|
Roles.CreateRole (adminRoleName);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2014-09-23 12:25:41 +02:00
|
|
|
|
[HttpGet]
|
|
|
|
|
|
[Authorize]
|
|
|
|
|
|
public long CreateEstimate (string title)
|
|
|
|
|
|
{
|
2014-10-08 10:47:40 +02:00
|
|
|
|
return WorkFlowManager.CreateEstimate (
|
2014-09-23 12:25:41 +02:00
|
|
|
|
Membership.GetUser().UserName,title);
|
|
|
|
|
|
}
|
2014-10-06 03:05:57 +02:00
|
|
|
|
|
2014-09-24 16:19:23 +02:00
|
|
|
|
[HttpGet]
|
|
|
|
|
|
[Authorize]
|
|
|
|
|
|
public void DropWritting(long wrid)
|
|
|
|
|
|
{
|
2014-10-08 10:47:40 +02:00
|
|
|
|
WorkFlowManager.DropWritting (wrid);
|
2014-09-24 16:19:23 +02:00
|
|
|
|
}
|
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
|
|
|
|
}
|
2014-09-23 12:25:41 +02:00
|
|
|
|
|
2014-09-24 16:19:23 +02:00
|
|
|
|
[HttpGet]
|
|
|
|
|
|
[Authorize]
|
|
|
|
|
|
public void DropEstimate(long estid)
|
|
|
|
|
|
{
|
2014-10-08 10:47:40 +02:00
|
|
|
|
WorkFlowManager.DropEstimate (estid);
|
2014-09-24 16:19:23 +02:00
|
|
|
|
}
|
2014-10-12 15:22:45 +02:00
|
|
|
|
|
2014-07-16 20:35:03 +02:00
|
|
|
|
[HttpGet]
|
2014-09-18 13:58:43 +02:00
|
|
|
|
[Authorize]
|
2014-07-16 20:35:03 +02:00
|
|
|
|
public object Index()
|
|
|
|
|
|
{
|
2014-09-24 16:19:23 +02:00
|
|
|
|
// 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-09-18 13:58:43 +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
|
2014-10-08 10:47:40 +02:00
|
|
|
|
return WorkFlowManager.Write(estid, desc, ucost, count, productid);
|
2014-09-18 13:58:43 +02:00
|
|
|
|
}
|
2014-07-16 20:35:03 +02:00
|
|
|
|
}
|
|
|
|
|
|
}
|