project structure and namespaces
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
namespace LaaProduction.Web.Controllers
|
||||
{
|
||||
using LaaProduction.Personalization;
|
||||
|
||||
using LaaProduction.Web.App_Infrastructure;
|
||||
using LaaProduction.Services.Interfaces;
|
||||
using LaaProduction.Services.Models;
|
||||
|
||||
using System;
|
||||
using System.Web.Mvc;
|
||||
|
||||
[AllowedRoles(UsersRoles.WEB_ProdApproval)]
|
||||
public class ApprovalsController : Controller
|
||||
{
|
||||
private readonly IApprovalsService approvals;
|
||||
|
||||
public ApprovalsController()
|
||||
=> this.approvals = ServiceProvider.GetService<IApprovalsService>();
|
||||
|
||||
[HttpGet]
|
||||
public ActionResult Add()
|
||||
=> this.View(new ProductionApproval
|
||||
{
|
||||
ApproverName = this.User.FullName(),
|
||||
ApprovalDate = DateTime.Now
|
||||
});
|
||||
|
||||
[HttpPost]
|
||||
public ActionResult Add(ProductionApproval approval)
|
||||
{
|
||||
if (this.ModelState.IsValid)
|
||||
{
|
||||
approval.ApprovalDate = DateTime.Now;
|
||||
approval.ApproverName = this.User.FullName();
|
||||
|
||||
var addResult = this.approvals.Add(approval);
|
||||
|
||||
if (addResult)
|
||||
{
|
||||
this.TempData["Success"] = (string)addResult;
|
||||
|
||||
return this.RedirectToAction(nameof(this.Add));
|
||||
}
|
||||
|
||||
this.TempData["Error"] = (string)addResult;
|
||||
}
|
||||
|
||||
return this.View(approval);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user