public IActionResult Assign(int id) { var modelitem = new ApprovalLevelAssignViewModel(); modelitem.EmployeeId = id; modelitem.FirstApprovers = this.Approvers(id); modelitem.SecondApprovers = this.Approvers(id); modelitem.Name = _Services.GetNameById(id); modelitem.EmployeeId = id; var _item = _Services.ApprovalAssignmentByEmployee(id); if (_item != null) { var item = new ApprovalLevelItemViewModel { Id = _item.Id, EmployeeId = _item.Id, FirstApprovalId = _item.FirstApproval.Id, SecondApprovalId = _item.SecondApproval == null ? 0 : _item.SecondApproval.Id, IsWithSecondApproval = _item.IsWithSecondApproval ? "on" : "off" }; modelitem.ApprovalLevel = item; } return(View(modelitem)); }
public IActionResult Save(ApprovalLevelAssignViewModel model) { var userId = int.Parse(HttpContext.Session.GetString("UserId")); if (model.ApprovalLevel != null) { var approvalLevel = new ApprovalLevelAssignment { Id = model.ApprovalLevel.Id, Employee = _Services.GetAccountById(model.ApprovalLevel.EmployeeId), FirstApproval = _Services.GetAccountById(model.ApprovalLevel.FirstApprovalId), SecondApproval = model.ApprovalLevel.IsWithSecondApproval == "on" ? _Services.GetAccountById(model.ApprovalLevel.SecondApprovalId) : null, IsWithSecondApproval = model.ApprovalLevel.IsWithSecondApproval == "on" ? true : false }; _Services.Save(approvalLevel, userId); return(RedirectToAction("Index")); } else { return(RedirectToAction("Index")); } }