public async Task <IActionResult> AssignUsersToAssignment(AssignUsersToAssignmentViewModel newAssignViewModel, Guid id, Guid AssignmentId) { ViewBag.AvailableTeamUsers = new SelectList(await _assignmentService.GetListOfAvailableAssignmentUsers(id, AssignmentId), "Id", "MemberName"); if (ModelState.IsValid) { Guid guidid = Guid.Parse(newAssignViewModel.AppUserId); UserAssignment userAssignment = new UserAssignment { AppUser = await _userManager.FindByIdAsync(newAssignViewModel.AppUserId), AppUserId = guidid, Assignment = await _assignmentService.GetAssignmentById(AssignmentId), AssignmentId = AssignmentId }; await _assignmentService.AddUserAssignment(userAssignment); List <AppUser> AssignmentMemberList = await _assignmentService.GetAssignmentUserList(AssignmentId); if (AssignmentMemberList.Count > 0) { await _assignmentService.ChangeStatusToInProgress(AssignmentId); } return(RedirectToAction("AssignUsersToAssignment", new { AssignmentId })); } return(RedirectToAction("AssignUsersToAssignment", new { AssignmentId })); }