public async Task <IActionResult> Submit(SubmissionIndexModel model) { int redirectId = 0; if (ModelState.IsValid && model != null) { var currentUser = await _userManager.GetUserAsync(User).ConfigureAwait(false); var now = DateTime.Now; var newBug = new Bug() { Urgency = _bug.GetUrgencyByName(model.Urgency), Title = model.Title, Owner = _bug.GetTeamByName(model.Team), AssignedTo = model.Developer == null ? null : await _userManager.FindByNameAsync(model.Developer).ConfigureAwait(false), CreatedOn = now, Description = model.Description, LogDetail = _bug.CreateEmptyLog(), ProjectAffected = _bug.GetProjectByName(model.ProjectAffected), Status = _bug.GetStatusByName("Open"), CreatedBy = currentUser }; redirectId = _bug.Add(newBug); } return(LocalRedirect("/Bug/Detail/" + redirectId.ToString())); }
public async Task <IActionResult> AssignEntityToProjectAsync(ProjectIndexModel model) { if (model != null) { var project = _bug.GetProjectByName(model.UpdateModel.ProjectName); if (User.IsInRole("Manager")) { var user = await _userManager.FindByNameAsync(model.UpdateModel.Username) .ConfigureAwait(false); _userBug.AssignUserToProject(user, project); } else { var team = _bug.GetTeamByName(model.UpdateModel.Team); _userBug.AssignTeamToProject(team, project); } } return(RedirectToAction("ManageProjects", "Management")); }