public ActionResult Details(int?id) { TaskDetailsVm model = new TaskDetailsVm(); model.PagerComment = model.PagerComment ?? new Pager(); model.PagerLogWork = model.PagerLogWork ?? new Pager(); model.FilterComment = model.FilterComment ?? new CommentsFilter(); model.FilterLoggedWorks = model.FilterLoggedWorks ?? new LoggedWorksFilter(); TryUpdateModel(model); TaskRepo repository = RepositoryFactory.GetTasksRepository(); Task task = repository.GetById(Convert.ToInt32(id)); model.Id = task.Id; model.UserId = task.UserId; model.Title = task.Title; model.Description = task.Description; model.ResponsibleUser = task.ResponsibleUser; model.Creator = task.Creator; model.Status = task.Status; model.LastChange = task.LastChange; model.CreateTime = task.CreateTime; CommentRepo comRepo = RepositoryFactory.GetCommentsRepository(); LoggedWorkRepo logWorkRepo = RepositoryFactory.GetLoggedWorksRepository(); string action = this.ControllerContext.RouteData.Values["action"].ToString(); string controller = this.ControllerContext.RouteData.Values["controller"].ToString(); //comments model.FilterComment.Prefix = "FilterComment."; string commentsPrefix = "PagerComment."; model.FilterComment.TaskId = task.Id; int commentsResultCount = comRepo.Count(model.FilterComment.BuildFilter()); model.PagerComment = new Pager(commentsResultCount, model.PagerComment.CurrentPage, model.PagerComment.PageSize, commentsPrefix, action, controller); model.FilterComment.ParentPager = model.PagerComment; model.CommentsList = comRepo.GetAll(model.FilterComment.BuildFilter(), model.PagerComment.CurrentPage, model.PagerComment.PageSize.Value).ToList(); //loggedwork model.FilterLoggedWorks.Prefix = "FilterLoggedWorks."; string loggedWorkPrefix = "PagerLogWork."; model.FilterLoggedWorks.TaskId = task.Id; int loggedWorkResultCount = logWorkRepo.Count(model.FilterLoggedWorks.BuildFilter()); model.PagerLogWork = new Pager(loggedWorkResultCount, model.PagerLogWork.CurrentPage, model.PagerLogWork.PageSize, loggedWorkPrefix, action, controller); model.FilterLoggedWorks.ParentPager = model.PagerLogWork; model.LoggedWorkList = logWorkRepo.GetAll(model.FilterLoggedWorks.BuildFilter(), model.PagerLogWork.CurrentPage, model.PagerLogWork.PageSize.Value).ToList(); return(View(model)); }
protected override void DeleteFilter(int id) { CommentRepo comRepository = RepositoryFactory.GetCommentsRepository(); List <Comment> comments = comRepository.GetAll().FindAll(com => com.TaskId == id); foreach (var com in comments) { comRepository.Delete(com); } LoggedWorkRepo loggedWorkRepo = RepositoryFactory.GetLoggedWorksRepository(); List <LoggedWork> loggedWorks = loggedWorkRepo.GetAll().FindAll(lw => lw.TaskId == id); foreach (var lw in loggedWorks) { loggedWorkRepo.Delete(lw); } }
protected override void DeleteFilter(int id) { TaskRepo taskRepository = RepositoryFactory.GetTasksRepository(); List <Task> tasks = taskRepository.GetAll().FindAll(task => task.UserId == id && task.ResponsibleUser == id); foreach (var task in tasks) { taskRepository.Delete(task); } List <Task> tasksRespU = taskRepository.GetAll(); foreach (var task in tasksRespU) { if (task.ResponsibleUser == AuthenticationManager.LoggedUser.Id) { task.UserId = AuthenticationManager.LoggedUser.Id; taskRepository.Save(task); } } CommentRepo comRepository = RepositoryFactory.GetCommentsRepository(); List <Comment> comments = comRepository.GetAll().FindAll(com => com.CreatedBy == id); foreach (var com in comments) { comRepository.Delete(com); } LoggedWorkRepo loggedWorkRepo = RepositoryFactory.GetLoggedWorksRepository(); List <LoggedWork> loggedWorks = loggedWorkRepo.GetAll().FindAll(lw => lw.UserId == id); foreach (var lw in loggedWorks) { loggedWorkRepo.Delete(lw); } }
private void GetAll(Entities.Task task) { var logedUser = AuthenticationService.LoggedUser; LoggedWorkRepo repo = new LoggedWorkRepo("worktime.txt"); var time = repo.GetAll(); Console.Clear(); foreach (var t in time) { if (t.TaskId == task.Id) { Console.Write("Created by ID: "); Console.WriteLine(t.UserId); Console.Write("Logged on: "); Console.WriteLine(t.LoggedOn); Console.Write("LOGWORK: "); Console.WriteLine(t.TimeSpent); Console.WriteLine("###############################"); } } Console.ReadKey(); Console.Clear(); View(task); }