public ActionResult Edit(EditIssueForm form) { if (!ModelState.IsValid) { return JsonValidationError(); } var issue = _context.Issues.SingleOrDefault(i => i.IssueID == form.IssueID); if (issue == null) { return JsonError("Cannot find the issue specified."); } var assignedToUser = _context.Users.Single(u => u.UserName == form.AssignedToUserName); issue.Subject = form.Subject; issue.AssignedTo = assignedToUser; issue.Body = form.Body; issue.IssueType = form.IssueType; return JsonSuccess(form); }
public ActionResult Edit(EditIssueForm form) { if (!ModelState.IsValid) { form.AvailableUsers = GetAvailableUsers(); form.AvailableIssueTypes = GetAvailableIssueTypes(); return View(form); } var issue = _context.Issues.SingleOrDefault(i => i.IssueID == form.IssueID); if (issue == null) { throw new ApplicationException("Issue not found!"); } var assignedToUser = _context.Users.Single(u => u.Id == form.AssignedToUserID); issue.Subject = form.Subject; issue.AssignedTo = assignedToUser; issue.Body = form.Body; issue.IssueType = form.IssueType; return RedirectToAction("View", new { id = form.IssueID }); }