public async Task <ActionResult> AssignStaff(AssignStaffViewModel viewModel) { if (ModelState.IsValid) { using (REMSDAL dal = new REMSDAL()) { var user = UserManager.Users.SingleOrDefault(u => u.UserName == viewModel.UserName); var staffMember = dal.StaffMembers.SingleOrDefault(s => s.Id == viewModel.StaffId); staffMember.UserId = user.UserName; var result = await dal.SaveChangesAsync(); // ^^^ NEW CODE ^^^ if (result > 0) { viewModel.ActionStatusMessageViewModel.StatusMessage = "Staff member " + staffMember.FirstName + staffMember.LastName + " updated."; viewModel.Users = GetUserNames(); //viewModel.StaffMembers = dal.StaffMembers.SingleOrDefault(s => s.Id == viewModel.StaffId); return(View(viewModel)); } } } // If we got this far, something failed, redisplay form viewModel.Users = GetUserNames(); viewModel.ActionStatusMessageViewModel.StatusMessage = "There was an issue processing your request."; return(View(viewModel)); }
public ActionResult AssignStaff() { AssignStaffViewModel viewModel = new AssignStaffViewModel(); viewModel.Users = GetUserNames(); return(View(viewModel)); }
public IActionResult PersonnelAta(AssignStaffViewModel model) { var user = _userManager.Users.FirstOrDefault(ı => ı.Id == model.StaffId); var duty = _taskBusiness.GetUrcenyId(model.DutyId).Data; if (user != null) { duty.User = user; } return(View(duty)); }
public IActionResult PersonnelCreate(AssignStaffViewModel model) { var update = _taskBusiness.GetById(model.DutyId); update.Data.UserId = model.StaffId; var data = _taskBusiness.Update(update.Data); if (data.IsSuccess) { return(RedirectToAction("Index")); } return(View()); }