public ActionResult Save(DepartmentDelegation departmentDelegation) { departmentDelegation.DepartmentId = User.Identity.GetDepartmentId(); departmentDelegationService.Save(departmentDelegation); return(RedirectToAction("Index", "DepartmentDelegation")); }
public IHttpActionResult CreateDelegation([FromBody] DepartmentDelegationMobileViewModel viewModel) { var delegation = new DepartmentDelegation() { Id = viewModel.UserId, DepartmentId = viewModel.DepartmentId, StartDate = viewModel.StartDate, EndDate = viewModel.EndDate }; departmentDelegationService.Save(delegation); return(Ok()); }
public ActionResult SaveDelegation(DepartmentDelegation delegation) { // Get username var usersContext = new ApplicationDbContext(); var username = usersContext.Users.Where(x => x.Id == delegation.UserId).FirstOrDefault().Email; // Save department delegation delegation.UserName = username; delegation.Status = CustomStatus.isActive; departmentDelegationService.Save(delegation); // Check if date is between date range var deptDelegation = departmentDelegationService.Get(delegation.Id); return(RedirectToAction("Delegation")); }
public void Save(DepartmentDelegation departmentDelegation) { DepartmentDelegation dd = departmentDelegationContext.Get(departmentDelegation.Id); if (dd == null) { departmentDelegationContext.Add(departmentDelegation); } else { dd.StartDate = departmentDelegation.StartDate; dd.EndDate = departmentDelegation.EndDate; dd.DepartmentId = departmentDelegation.DepartmentId; dd.UserId = departmentDelegation.UserId; dd.Status = departmentDelegation.Status; } departmentDelegationContext.Commit(); }