public ActionResult New() { var form = new NewIssueForm { }; return(View(form)); }
public ActionResult New(NewIssueForm form) { _context.Issues.Add(new Issue(_currentUser.User, form.Subject, form.Body)); _context.SaveChanges(); return(RedirectToAction("Index", "Home")); }
public ActionResult New() { var form = new NewIssueForm { AvailableUsers = GetAvailableUsers(), AvailableIssueTypes = GetAvailableIssueTypes() }; return(View(form)); }
public ActionResult New(NewIssueForm form) { var assignedToUser = _context.Users.Find(form.AssignedToUserId); _context.Issues.Add(new Issue(_currentUser.User, form.Subject, form.Body, assignedToUser)); _context.SaveChanges(); return(RedirectToAction <HomeController>(c => c.Index()) .WithSuccess("Issue created!")); }
public ActionResult New(NewIssueForm form) { if (!ModelState.IsValid) { return(View(form)); } var assignedToUser = _context.Users.Single(u => u.Id == form.AssignedToUserID); _context.Issues.Add(new Issue(_currentUser.User, assignedToUser, form.IssueType, form.Subject, form.Body)); _context.SaveChanges(); return(RedirectToAction <HomeController>(c => c.Index()) .WithSuccess("Issue created!")); }
public ActionResult New(NewIssueForm form) { if (!ModelState.IsValid) { form.AvailableUsers = GetAvailableUsers(); form.AvailableIssueTypes = GetAvailableIssueTypes(); return(View(form)); } var assignedToUser = _context.Users.Single(u => u.Id == form.AssignedToUserID); _context.Issues.Add(new Issue(_currentUser.User, assignedToUser, form.IssueType, form.Subject, form.Body)); _context.SaveChanges(); return(RedirectToAction("Index", "Home")); }