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(); [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); } } }