// Details public override TaskDetailsVM PopulateDetailsModel(TaskDetailsVM model) { TryUpdateModel(model); BaseService <Task> taskService = GetService(); UserService userService = new UserService(); LogworkService logworkService = new LogworkService(); CommentService commentService = new CommentService(); Task task = taskService.GetByID(model.ID); model.Title = task.Title; model.Description = task.Description; model.WorkingHours = task.WorkingHours; model.Creator = userService.GetByID(task.CreatorID).Username; model.Responsible = userService.GetByID(task.ResponsibleID).Username; model.CreateDate = task.CreateDate; model.LastEditDate = task.LastEditDate; model.Status = task.Status; model.Logworks = logworkService.GetAll(l => l.TaskID == task.ID); model.Comments = commentService.GetAll(c => c.TaskID == task.ID); //Pager model.LogworksPager = new Pager(model.Logworks.Count, model.LogworksPager == null ? 1 : model.LogworksPager.CurrentPage, "LogworksPager.", "Details", "Task", model.LogworksPager == null ? 3 : model.LogworksPager.PageSize); model.Logworks = model.Logworks.Skip((model.LogworksPager.CurrentPage - 1) * model.LogworksPager.PageSize).Take(model.LogworksPager.PageSize).ToList(); model.CommentsPager = new Pager(model.Comments.Count, model.CommentsPager == null ? 1 : model.CommentsPager.CurrentPage, "CommentsPager.", "Details", "Task", model.CommentsPager == null ? 3 : model.CommentsPager.PageSize); model.Comments = model.Comments.Skip((model.CommentsPager.CurrentPage - 1) * model.CommentsPager.PageSize).Take(model.CommentsPager.PageSize).ToList(); return(model); }
public ActionResult CreateLogwork(TaskCreateLogworkVM model) { if (!ModelState.IsValid) { return(View(model)); } Logwork logwork = new Logwork() { TaskID = model.TaskID, UserID = AuthenticationManager.LoggedUser.ID, WorkingHours = model.WorkingHours, CreateDate = DateTime.Now }; LogworkService logworkService = new LogworkService(); logworkService.Save(logwork); return(RedirectToAction("Details", new { id = model.TaskID })); }