public override void ExtraDelete(Task task)
        {
            LogWorkRepo repoWork    = new LogWorkRepo();
            CommentRepo repoComment = new CommentRepo();

            List <Comment> comments = repoComment.GetAll().ToList();
            List <LogWork> work     = repoWork.GetAll().ToList();

            foreach (Comment item in comments)
            {
                if (item.taskId == task.Id)
                {
                    repoComment.Delete(item);
                }
            }


            foreach (LogWork item in work)
            {
                if (item.TaskId == task.Id)
                {
                    repoWork.Delete(item);
                }
            }
        }
        public override void ExtraDelete(User user)
        {
            TaskRepo    repoTask    = new TaskRepo();
            LogWorkRepo repoWork    = new LogWorkRepo();
            CommentRepo repoComment = new CommentRepo();

            List <Task>    tasks    = repoTask.GetAll(t => t.creatorId == user.Id).ToList();
            List <Comment> comments = repoComment.GetAll().ToList();
            List <LogWork> works    = repoWork.GetAll().ToList();

            foreach (Task item in tasks)
            {
                foreach (Comment comment in comments)
                {
                    if (comment.taskId == item.Id)
                    {
                        repoComment.Delete(comment);
                    }
                }

                foreach (LogWork work in works)
                {
                    if (work.TaskId == item.Id)
                    {
                        repoWork.Delete(work);
                    }
                }

                repoTask.Delete(item);
            }
        }
        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));
        }
Пример #4
0
        public async Task <IActionResult> Index()
        {
            var model = new MainViewModel();

            model.User             = currentUser;
            model.EventSearchModel = Search(model.EventSearchModel);

            model.Purchases = await PurchaseRepp.GetAll().Where(x => x.UserId == currentUser.Id).ToListAsync();

            model.Comments = await CommentRepo.GetAll().Where(x => x.UserId == currentUser.Id).ToListAsync();

            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);
            }
        }
Пример #7
0
        private void GetAllComments(Entities.Task task)
        {
            var         logedUser = AuthenticationService.LoggedUser;
            CommentRepo repo      = new CommentRepo("comments.txt");
            var         coms      = repo.GetAll();

            Console.Clear();
            foreach (var com in coms)
            {
                if (com.ParentId == task.Id)
                {
                    Console.Write("Created by ID: ");
                    Console.WriteLine(com.CreatedBy);
                    Console.Write("Comments: ");
                    Console.WriteLine(com.Comments);
                    Console.WriteLine("###############################");
                }
            }
            Console.ReadKey();
            Console.Clear();
            DetailMenuVIew detailMenu = new DetailMenuVIew();

            detailMenu.PrintRepo(task);
        }
        public ActionResult Details(int id)
        {
            TaskRepo repo = new TaskRepo();
            Task     task = repo.GetById(id);

            if (task.assignetId != AuthenticationManager.LoggedUser.Id && task.creatorId != AuthenticationManager.LoggedUser.Id)
            {
                return(RedirectToAction("Index", "TaskManagement"));
            }

            DetailsTaskVM model = new DetailsTaskVM();

            model.CommentsVM   = new ListCommentVM();
            model.LoggedWorkVM = new ListLogVM();

            UserRepo    repoUser = new UserRepo();
            List <User> users    = repoUser.GetAll().ToList();

            CommentRepo    repoComment = new CommentRepo();
            List <Comment> comments    = repoComment.GetAll(c => c.taskId == id).ToList();

            LogWorkRepo    repoWork = new LogWorkRepo();
            List <LogWork> works    = repoWork.GetAll(w => w.TaskId == id).ToList();

            model.Id           = task.Id;
            model.Tittle       = task.tittle;
            model.Content      = task.content;
            model.WorkingHours = task.estimate;
            model.AssigneeId   = task.assignetId;
            model.CreatorId    = task.creatorId;
            model.CreateOn     = task.createdON;
            model.EditedBy     = task.editedBY;
            model.EditedOn     = task.editedON;
            model.Status       = task.finnished;

            model.users = new List <User>();
            foreach (User item in users)
            {
                model.users.Add(item);
            }

            model.CommentsVM.Items = new List <Comment>();
            foreach (Comment item in comments)
            {
                model.CommentsVM.Items.Add(item);
            }

            model.LoggedWorkVM.Items = new List <LogWork>();
            foreach (LogWork item in works)
            {
                model.LoggedWorkVM.Items.Add(item);
            }

            model.CommentsVM.Pager         = new PagerVM();
            model.CommentsVM.Filter        = new CommentFilterVM();
            model.CommentsVM.Pager.Prefix  = "CommentsVM.Pager.";
            model.CommentsVM.Filter.Prefix = "CommentsVM.Filter.";
            model.CommentsVM.Filter.Pager  = model.CommentsVM.Pager;

            model.LoggedWorkVM.Pager         = new PagerVM();
            model.LoggedWorkVM.Filter        = new LogWorkFilterVM();
            model.LoggedWorkVM.Pager.Prefix  = "LoggedWorkVM.Pager.";
            model.LoggedWorkVM.Filter.Prefix = "LoggedWorkVM.Filter.";
            model.LoggedWorkVM.Filter.Pager  = model.LoggedWorkVM.Pager;

            TryUpdateModel(model);

            Expression <Func <Comment, bool> > commentFilter = model.CommentsVM.Filter.GenerateFilter();

            model.CommentsVM.Items = repoComment.GetAll(commentFilter, model.CommentsVM.Pager.CurrentPage, model.CommentsVM.Pager.PageSize).ToList();

            Expression <Func <LogWork, bool> > workFilter = model.LoggedWorkVM.Filter.GenerateFilter();

            model.LoggedWorkVM.Items = repoWork.GetAll(workFilter, model.LoggedWorkVM.Pager.CurrentPage, model.LoggedWorkVM.Pager.PageSize).ToList();

            model.CommentsVM.Pager.PagesCount = (int)Math.Ceiling(model.CommentsVM.Items.Count / (double)model.CommentsVM.Pager.PageSize);
            model.CommentsVM.Items            = model.CommentsVM.Items.Skip(model.CommentsVM.Pager.PageSize * (model.CommentsVM.Pager.CurrentPage - 1)).Take(model.CommentsVM.Pager.PageSize).ToList();

            model.LoggedWorkVM.Pager.PagesCount = (int)Math.Ceiling(model.LoggedWorkVM.Items.Count / (double)model.LoggedWorkVM.Pager.PageSize);
            model.LoggedWorkVM.Items            = model.LoggedWorkVM.Items.Skip(model.LoggedWorkVM.Pager.PageSize * (model.LoggedWorkVM.Pager.CurrentPage - 1)).Take(model.LoggedWorkVM.Pager.PageSize).ToList();

            return(View(model));
        }