public ActionResult New(string id) { BugManager manager = new BugManager(); BugSummary summary = (BugSummary)manager.NewItem(); if (!string.IsNullOrWhiteSpace(id)) summary.Title = id; MSAgileEditData<BugSummary> data = new MSAgileEditData<BugSummary>(); data.PageTitle = "New bug"; data.States = summary.ValidStates; data.Reasons = summary.ValidReasons; data.Priorities = summary.ValidPriorities; data.Severities = summary.ValidSeverities; data.WorkItem = summary; return View("Edit", data); }
public ActionResult Edit(BugSummary item,string fromUrl) { BugManager manager = new BugManager(); try { item.IsNew = false; manager.Save(item); // Save the files once it's saved (as we can't add an AttachmentsCollection as it has no constructors) if (Request.Files.Count > 0) { try { // Save to the App_Data folder. List<Attachment> attachments = new List<Attachment>(); string filename1 = SaveFile("uploadFile1", item.Id); string filename2 = SaveFile("uploadFile2", item.Id); string filename3 = SaveFile("uploadFile3", item.Id); if (!string.IsNullOrEmpty(filename1)) { attachments.Add(new Attachment(filename1, Request.Form["uploadFile1Comments"])); } if (!string.IsNullOrEmpty(filename2)) { attachments.Add(new Attachment(filename2, Request.Form["uploadFile2Comments"])); } if (!string.IsNullOrEmpty(filename3)) { attachments.Add(new Attachment(filename3, Request.Form["uploadFile3Comments"])); } manager.SaveAttachments(item.Id, attachments); } catch (IOException e) { TempData["Error"] = e.Message; return RedirectToAction("Edit", new { id = item.Id }); } } if (string.IsNullOrEmpty(fromUrl)) return RedirectToAction("View", new { id = item.Id }); else return Redirect(fromUrl); } catch (SaveException e) { TempData["Error"] = e.Message; // Get the original back, to populate the valid reasons. QueryManager queryManager = new QueryManager(); BugSummary summary = queryManager.ItemById<BugSummary>(item.Id); summary.IsNew = false; // Repopulate from the POST'd data summary.Title = item.Title; summary.State = item.State; summary.Reason = item.Reason; summary.Priority = item.Priority; summary.Severity = item.Severity; summary.Description = item.Description; summary.AssignedTo = item.AssignedTo; summary.AreaId = item.AreaId; summary.AreaPath = item.AreaPath; summary.IterationId = item.IterationId; summary.IterationPath = item.IterationPath; MSAgileEditData<BugSummary> data = new MSAgileEditData<BugSummary>(); data.WorkItem = summary; data.PageTitle = "Bug " + item.Id; data.FromUrl = fromUrl; data.States = summary.ValidStates; data.Reasons = summary.ValidReasons; data.Priorities = summary.ValidPriorities; data.Severities = summary.ValidSeverities; return View(data); } }
public ActionResult New(BugSummary item) { BugManager manager = new BugManager(); try { item.CreatedBy = UserContext.Current.Name; item.IsNew = true; manager.Save(item); // item.Id is updated // Save the files once it's saved (as we can't add an AttachmentsCollection as it has no constructors) if (Request.Files.Count > 0) { try { // Save to the App_Data folder. List <Attachment> attachments = new List <Attachment>(); string filename1 = SaveFile("uploadFile1", item.Id); string filename2 = SaveFile("uploadFile2", item.Id); string filename3 = SaveFile("uploadFile3", item.Id); if (!string.IsNullOrEmpty(filename1)) { attachments.Add(new Attachment(filename1, Request.Form["uploadFile1Comments"])); } if (!string.IsNullOrEmpty(filename2)) { attachments.Add(new Attachment(filename2, Request.Form["uploadFile2Comments"])); } if (!string.IsNullOrEmpty(filename3)) { attachments.Add(new Attachment(filename3, Request.Form["uploadFile3Comments"])); } manager.SaveAttachments(item.Id, attachments); } catch (IOException e) { TempData["Error"] = e.Message; return(RedirectToAction("Edit", new { id = item.Id })); } } return(RedirectToAction("Index")); } catch (SaveException e) { TempData["Error"] = e.Message; // Get the original back, to populate the valid reasons. QueryManager queryManager = new QueryManager(); BugSummary summary = queryManager.ItemById <BugSummary>(item.Id); summary.IsNew = false; // Repopulate from the POST'd data summary.Title = item.Title; summary.State = item.State; summary.Reason = item.Reason; summary.Priority = item.Priority; summary.Severity = item.Severity; summary.Description = item.Description; summary.AssignedTo = item.AssignedTo; summary.AreaId = item.AreaId; summary.AreaPath = item.AreaPath; summary.IterationId = item.IterationId; summary.IterationPath = item.IterationPath; MSAgileEditData <BugSummary> data = new MSAgileEditData <BugSummary>(); data.WorkItem = summary; data.PageTitle = "Bug " + item.Id; data.States = summary.ValidStates; data.Reasons = summary.ValidReasons; data.Priorities = summary.ValidPriorities; data.Severities = summary.ValidSeverities; return(View(data)); } }