Esempio n. 1
0
        public ActionResult Edit(int id, string fromUrl)
        {
            QueryManager manager = new QueryManager();
            TaskSummary  item    = manager.ItemById <TaskSummary>(id);

            item.IsNew = false;

            // Change the user's current project if this work item is different.
            // The project can be different if they've come from the stored queries page.
            if (item.ProjectName != UserContext.Current.CurrentProject.Name)
            {
                UserContext.Current.ChangeCurrentProject(item.ProjectName);
            }

            MSAgileEditData <TaskSummary> data = new MSAgileEditData <TaskSummary>();

            data.WorkItem   = item;
            data.PageTitle  = "Task " + id;
            data.FromUrl    = fromUrl;
            data.States     = item.ValidStates;
            data.Reasons    = item.ValidReasons;
            data.Priorities = item.ValidPriorities;
            data.Severities = item.ValidSeverities;

            return(View(data));
        }
Esempio n. 2
0
        public ActionResult New(string id)
        {
            IssueManager manager = new IssueManager();
            IssueSummary summary = (IssueSummary)manager.NewItem();

            if (!string.IsNullOrWhiteSpace(id))
            {
                summary.Title = id;
            }

            MSAgileEditData <IssueSummary> data = new MSAgileEditData <IssueSummary>();

            data.PageTitle  = "New issue";
            data.States     = summary.ValidStates;
            data.Reasons    = summary.ValidReasons;
            data.Priorities = summary.ValidPriorities;
            data.WorkItem   = summary;

            return(View("Edit", data));
        }
Esempio n. 3
0
        public ActionResult New(TaskSummary item)
        {
            TaskManager manager = new TaskManager();

            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();
                TaskSummary  summary      = queryManager.ItemById <TaskSummary>(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.Description   = item.Description;
                summary.AssignedTo    = item.AssignedTo;
                summary.AreaId        = item.AreaId;
                summary.AreaPath      = item.AreaPath;
                summary.IterationId   = item.IterationId;
                summary.IterationPath = item.IterationPath;

                MSAgileEditData <TaskSummary> data = new MSAgileEditData <TaskSummary>();
                data.WorkItem   = summary;
                data.PageTitle  = "Task " + item.Id;
                data.States     = summary.ValidStates;
                data.Reasons    = summary.ValidReasons;
                data.Priorities = summary.ValidPriorities;
                data.Severities = summary.ValidSeverities;

                return(View(data));
            }
        }