public ActionResult Details(int id) { var model = new ProjectFormModel(); var project = ProjectRepository.ProjectFetch(id); model.Title = string.Format("Project {0}", project.Name); model.Project = project; model.Notes = NoteRepository.NoteFetchInfoList(id, SourceType.Project); model.Attachments = AttachmentRepository.AttachmentFetchInfoList( model.Notes.Select(row => row.NoteId).Distinct().ToArray(), SourceType.Note); model.Sprints = SprintRepository.SprintFetchInfoList(project); model.Statuses = StatusRepository.StatusFetchInfoList(id); model.Stories = StoryRepository.StoryFetchInfoList(project, false); model.Users = ProjectUserRepository.ProjectUserFetchInfoList(id); model.TimelineListModel = new TimelineListModel { Timelines = TimelineRepository.TimelineFetchInfoList(project), SourceId = project.SourceId, SourceTypeId = (int)project.SourceType }; model.Actions.Add("Edit this project", Url.Action("Edit", new { id }), "primary"); model.Actions.Add("Add a story", Url.Action("Create", "Story", new { projectId = id })); model.Actions.Add("Add a sprint", Url.Action("Create", "Sprint", new { projectId = id })); model.Actions.Add("Add an email", string.Empty); model.Actions.Add("Add a note", Url.Action("Create", "Note", new { sourceId = id, sourceTypeId = (int)SourceType.Project })); model.Actions.Add("Add a collaborator", Url.Action("Create", "ProjectUser", new { projectId = id })); model.Actions.Add("Add a status", Url.Action("Create", "Status", new { projectId = id })); return this.View(model); }
public ActionResult Create() { var model = new ProjectFormModel(); var project = ProjectRepository.ProjectNew(); model.Title = "Project Create"; model.Project = project; return this.View(model); }
public ActionResult Delete(int id) { var model = new ProjectFormModel(); try { var project = ProjectService.ProjectFetch(id); this.MapToModel(project, model, true); } catch (Exception ex) { this.ModelState.AddModelError(string.Empty, ex.Message); } return this.View(model); }
public ActionResult Create(ProjectFormModel model) { var project = ProjectService.ProjectNew(); Csla.Data.DataMapper.Map(model, project, true); project = ProjectService.ProjectSave(project); if (project.IsValid) { return new JsonResult { Data = this.Url.Action("Edit", new { id = project.ProjectId, message = Resources.SaveSuccessfulMessage }) }; } this.MapToModel(project, model, false); return this.View(model); }
public ActionResult Create(FormCollection collection) { var model = new ProjectFormModel(); var project = ProjectRepository.ProjectNew(); this.Map(collection, project); project = ProjectRepository.ProjectSave(project); if (project.IsValid) { return this.RedirectToAction("Details", new { id = project.ProjectId }); } model.Title = "Project Create"; model.Project = project; ModelHelper.MapBrokenRules(this.ModelState, project); return this.View(model); }
public ProjectFormModel MapToModel(Project project, ProjectFormModel model, bool ignoreBrokenRules) { Csla.Data.DataMapper.Map(project, model, true); model.Tab = "Project"; model.IsNew = project.IsNew; model.IsValid = project.IsValid; if (!project.IsNew) { model.Tasks = TaskService.TaskFetchInfoList(project); model.Sprints = SprintService.SprintFetchInfoList(project); model.Statuses = DataHelper.GetStatusList(); model.Categories = DataHelper.GetCategoryList(); model.NoteListModel = new NoteListModel { Source = project, Notes = NoteService.NoteFetchInfoList(project).AsQueryable() }; model.AttachmentListModel = new AttachmentListModel { Source = project, Attachments = AttachmentService.AttachmentFetchInfoList(project).AsQueryable() }; } if (!ignoreBrokenRules) { foreach (var brokenRule in project.BrokenRulesCollection) { this.ModelState.AddModelError(string.Empty, brokenRule.Description); } } return model; }
public ActionResult Edit(int id, ProjectFormModel model) { var project = ProjectService.ProjectFetch(id); Csla.Data.DataMapper.Map(model, project, true); project = ProjectService.ProjectSave(project); if (project.IsValid) { model.Message = Resources.SaveSuccessfulMessage; } this.MapToModel(project, model, true); return this.View(model); }
public ActionResult Edit(int id) { var model = new ProjectFormModel(); var project = ProjectRepository.ProjectFetch(id); model.Title = "Project Edit"; model.Project = project; return this.View(model); }