public ActionResult Status(int id)
        {
            TaskRepo repo = new TaskRepo();
            Task     task = repo.GetById(id);

            if (task.assignetId == AuthenticationManager.LoggedUser.Id || task.creatorId == AuthenticationManager.LoggedUser.Id)
            {
                if (task.finnished == true)
                {
                    task.finnished = false;
                }
                else
                {
                    task.finnished = true;
                }

                repo.Edit(task);

                return(RedirectToAction("Index", "TaskManagement"));
            }
            else
            {
                return(RedirectToAction("Index", "TaskManagement"));
            }
        }
        internal void View()
        {
            TaskManagerView taskView = new TaskManagerView();

            taskView.All();
            Console.WriteLine("*** CHOOSE BY ID TASK ADDITIONAL INFO ***");
            Console.Write("           ID: ");
            int id = int.Parse(Console.ReadLine());

            Console.Clear();
            TaskRepo repo = new TaskRepo("tasks.txt");

            PrintRepo(repo.GetById(id));
            Console.WriteLine();
            RenderMenu(repo.GetById(id));
            Console.Clear();
        }
        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 Delete()
        {
            Console.Clear();
            All();
            Console.WriteLine("*** CHOOSE BY ID WHO TO DELETE ***");
            Console.Write("           ID: ");
            int      id   = int.Parse(Console.ReadLine());
            TaskRepo repo = new TaskRepo("tasks.txt");

            repo.Delete(repo.GetById(id));
            Console.Clear();
            Console.WriteLine("*******************************");
            Console.WriteLine("********* COMPLETED!!! ********");
            Console.WriteLine("*******************************");
            Thread.Sleep(1500);
        }
        protected override void Edit()
        {
            Console.Clear();
            All();
            Console.WriteLine("*** CHOOSE BY ID WHO TO EDIT ***");
            Console.Write("         ID: ");
            int      id   = int.Parse(Console.ReadLine());
            TaskRepo repo = new TaskRepo("tasks.txt");
            Task     task = new Task();
            Task     u    = new Task();

            task       = repo.GetById(id);
            u.Id       = task.Id;
            u.ParentId = task.ParentId;
            Console.Write("******** OLD TITLE : ");
            Console.WriteLine(task.Title);
            Console.Write("******** NEW TITLE : ");
            u.Title = Console.ReadLine();
            Console.Write("******** OLD DESCRIPTION : ");
            Console.WriteLine(task.Description);
            Console.Write("******** OLD DESCRIPTION : ");
            u.Description = Console.ReadLine();
            Console.Write("******** OLD RESPONSIBLE USER ID : ");
            Console.WriteLine(task.ResponsibleUser);
            Console.Write("******** OLD RESPONSIBLE USER ID : ");
            u.ResponsibleUser = Convert.ToInt32(Console.ReadLine());
            Console.Write("******** OLD CREATOR : ");
            Console.WriteLine(task.Creator);
            Console.Write("******** NEW CREATOR : ");
            u.Creator = Console.ReadLine();
            Console.Write("******** OLD STATUS : ");
            Console.WriteLine(task.Status);
            Console.Write("******** NEW STATUS : ");
            u.Status = Convert.ToString(WhichStatus());
            var time = DateTime.Now;

            u.LastChange = time;
            u.CreateTime = task.CreateTime;
            repo.Save(u);
            Console.Clear();
            Console.WriteLine("*******************************");
            Console.WriteLine("********* COMPLETED!!! ********");
            Console.WriteLine("*******************************");
            Thread.Sleep(1500);
        }
Exemple #6
0
        public ActionResult CreateComment(int id)
        {
            TaskRepo repo = new TaskRepo();
            Task     task = repo.GetById(id);

            CreateCommentVM create = new CreateCommentVM();

            create.TaskId = task.Id;

            if (task.assignetId == AuthenticationManager.LoggedUser.Id || task.creatorId == AuthenticationManager.LoggedUser.Id)
            {
                return(View(create));
            }
            else
            {
                return(RedirectToAction("Index", "TaskManagement"));
            }
        }
        public ActionResult SetHours(int id)
        {
            TaskRepo repo = new TaskRepo();
            Task     task = repo.GetById(id);

            SetHoursVM set = new SetHoursVM();

            set.SetHours = 0;
            set.Id       = task.Id;

            if (task.assignetId == AuthenticationManager.LoggedUser.Id || task.creatorId == AuthenticationManager.LoggedUser.Id)
            {
                return(View(set));
            }
            else
            {
                return(RedirectToAction("Index", "TaskManagement"));
            }
        }
Exemple #8
0
        public ActionResult DeleteComment(int id)
        {
            if (AuthenticationManager.LoggedUser == null)
            {
                return(RedirectToAction("Login", "Home"));
            }

            CommentRepo repoComment = new CommentRepo();
            Comment     comment     = repoComment.GetById(id);

            TaskRepo repo = new TaskRepo();
            Task     task = repo.GetById(comment.taskId);


            if (comment.commentCreatorId == AuthenticationManager.LoggedUser.Id || task.creatorId == AuthenticationManager.LoggedUser.Id)
            {
                UserRepo    repoUser = new UserRepo();
                List <User> users    = repoUser.GetAll().ToList();

                DeleteCommentVM delete = new DeleteCommentVM();
                delete.users = new List <User>();

                delete.Id        = comment.Id;
                delete.Tittle    = comment.commentTittle;
                delete.Content   = comment.commentContent;
                delete.CreatorId = comment.commentCreatorId;
                delete.TaskId    = comment.taskId;
                delete.Date      = comment.Date;

                foreach (var item in users)
                {
                    delete.users.Add(item);
                }

                return(View(delete));
            }
            else
            {
                return(RedirectToAction("Details", "TaskManagement", new { id = comment.taskId }));
            }
        }
        public ActionResult SetHours(SetHoursVM set)
        {
            TaskRepo repo = new TaskRepo();
            Task     task = repo.GetById(set.Id);

            task.editedBY = AuthenticationManager.LoggedUser.Id;
            task.editedON = DateTime.Now;
            task.estimate = task.estimate + set.SetHours;

            repo.Edit(task);

            LogWorkRepo repoWork = new LogWorkRepo();
            LogWork     work     = new LogWork();

            work.TaskId   = task.Id;
            work.Username = AuthenticationManager.LoggedUser.Username;
            work.Email    = AuthenticationManager.LoggedUser.Email;
            work.Time     = set.SetHours;
            work.Date     = DateTime.Now;

            repoWork.Create(work);

            return(RedirectToAction("CreateComment", "CommentManagement", new { id = task.Id }));
        }
        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));
        }