Edition du devis fonctionnelle

This commit is contained in:
Paul Schneider 2014-10-20 07:23:44 +02:00
commit 2ac2338939
22 changed files with 347 additions and 74 deletions

View file

@ -21,9 +21,10 @@ namespace Yavsc.Controllers
public class FrontOfficeController : Controller
{
[Authorize]
public ActionResult Estimate(Estimate model,string submit)
public ActionResult Estimate(Estimate model,string submit)
{
if (ModelState.IsValid) {
ViewData ["WebApiUrl"] = "http://"+ Request.Url.Authority + "/api/WorkFlow";
string username = HttpContext.User.Identity.Name;
if (model.Id > 0) {
Estimate f = WorkFlowManager.GetEstimate (model.Id);
@ -31,7 +32,6 @@ namespace Yavsc.Controllers
ModelState.AddModelError ("Id", "Wrong Id");
return View (model);
}
if (username != f.Owner)
if (!Roles.IsUserInRole ("FrontOffice"))
throw new UnauthorizedAccessException ("You're not allowed to view/modify this estimate");

View file

@ -11,7 +11,6 @@ using System.Web.Security;
namespace Yavsc.ApiControllers
{
//[HttpControllerConfiguration(ActionValueBinder=typeof(Basic.MvcActionValueBinder))]
public class WorkFlowController : ApiController
{
string adminRoleName="Admin";
@ -39,10 +38,13 @@ namespace Yavsc.ApiControllers
{
WorkFlowManager.DropWritting (wrid);
}
[HttpGet]
[Authorize]
public void UpdateWritting(Writting wr)
[AcceptVerbs("POST")]
public void UpdateWritting([FromBody] Writting wr)
{
if (!ModelState.IsValid)
throw new Exception ("Modèle invalide");
WorkFlowManager.UpdateWritting (wr);
}
@ -62,12 +64,13 @@ namespace Yavsc.ApiControllers
return new { test=string.Format("Hello {0}!",username) };
}
[HttpGet]
[HttpPost]
[AcceptVerbs("POST")]
[Authorize]
public long Write (long estid, string desc, decimal ucost, int count, string productid) {
public long Write ([FromUri] long estid, [FromBody] Writting wr) {
// TODO ensure estid owner matches the current one
return WorkFlowManager.Write(estid, desc, ucost, count, productid);
return WorkFlowManager.Write(estid, wr.Description,
wr.UnitaryCost, wr.Count, wr.ProductReference);
}
}
}