public ActionResult Edit([Bind("Id,ProjectId,BugPriorityId,BugStatusId,BugCreatedBy,BugCreatedOn,BugClosedBy,BugClosedOn,BugResolutionSummary,Document")] BugsEditViewModel model) { Bugs bug = bugRepository.GetBugs(model.Id); try { if (ModelState.IsValid) { bug.ProjectId = model.ProjectId; bug.BugStatusId = model.BugStatusId; bug.BugPriorityId = model.BugPriorityId; bug.BugCreatedBy = model.BugCreatedBy; bug.BugCreatedOn = model.BugCreatedOn; bug.BugClosedBy = model.BugClosedBy; bug.BugClosedOn = model.BugClosedOn; bug.BugResolutionSummary = model.BugResolutionSummary; if (model.Document != null) { bug.Attachment = ProcessUploadedDocument(model); //Upload document to server } bugRepository.Update(bug); return(RedirectToAction(nameof(Index))); } } catch { return(NotFound()); } return(View()); }
public ActionResult Edit(int?Id) { Bugs bug = bugRepository.GetBugs(Id.Value); if (bug == null) { Response.StatusCode = 404; return(View("BugSearchedNotFound", Id.Value)); } //Instance of Bugs created and populate with data retrieved from Database //Bugs bugs = new Bugs BugsEditViewModel bugs = new BugsEditViewModel { Id = bug.Id, ProjectId = bug.ProjectId, BugPriorityId = bug.BugPriorityId, BugStatusId = bug.BugStatusId, BugCreatedBy = bug.BugCreatedBy, BugCreatedOn = bug.BugCreatedOn, BugClosedBy = bug.BugClosedBy, BugClosedOn = bug.BugClosedOn, BugResolutionSummary = bug.BugResolutionSummary, ExistingDocument = bug.Attachment }; if (bugs == null) { return(NotFound()); } ViewData["BugPriorityId"] = new SelectList(bugPriorityRepository.GetAllBugPriorities(), "Id", "BugPriorityType"); ViewData["BugStatusId"] = new SelectList(bugStatusRepository.GetAllBugStatus(), "Id", "BugStatusType"); ViewData["ProjectId"] = new SelectList(projectRepository.GetAllProjects(), "Id", "Name"); return(View(bugs)); }