51 lines
1.4 KiB
C#
51 lines
1.4 KiB
C#
namespace LaaProduction.Web.Controllers
|
|
{
|
|
using LaaProduction.Personalization;
|
|
using LaaProduction.Web.App_Infrastructure;
|
|
using LaaProduction.Services.Interfaces;
|
|
using LaaProduction.Services.Models;
|
|
using LaaProductionDI;
|
|
|
|
using System;
|
|
using System.Web.Mvc;
|
|
|
|
[AllowedRoles(EmployeesRoles.WEB_ProdApproval)]
|
|
public class ApprovalsController : Controller
|
|
{
|
|
private readonly IApprovalsService approvals;
|
|
|
|
public ApprovalsController()
|
|
=> this.approvals = LaaServiceProvider.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);
|
|
}
|
|
}
|
|
} |