Exemplo n.º 1
0
        public ActionResult ChangeTaskPosition(int taskId, int priority)
        {
            ProjectRepository projectRepo = new ProjectRepository();
            TaskRepository taskRepo = new TaskRepository();

            taskRepo.ChangeTaskPosition(taskId, priority);
            int projectId = taskRepo.GetTasks().FirstOrDefault(t=>t.Id == taskId).ProjectId;
            List<Task> tasks = taskRepo.GetTasks(projectId).ToList();
            int index = tasks.IndexOf(tasks.First(t => t.Id == taskId));

            //Task

            if (Request.IsAjaxRequest())
                return PartialView("TaskList", tasks);
            else
            {
                List<Project> projects = projectRepo.GetProjects(WebSecurity.CurrentUserId);
                List<Project> result = new List<Project>();

                foreach (var project in projects)
                {
                    var temp = project.Tasks.OrderByDescending(t => t.Priority);
                    Project pr = new Project();
                    pr.Tasks = temp.ToList();
                    result.Add(pr);
                }

                return View("MyToDoList", result);
            }
        }
Exemplo n.º 2
0
        public bool Delete(int TodoId, out string Error)
        {
            Error = string.Empty;

            TaskRepository _taskRepository = new TaskRepository();
            bool           status          = _taskRepository.DeleteByTodo(TodoId, out Error);

            if (status)
            {
                status = _todoContext.Delete(TodoId, out Error);
            }

            return(status);
        }
Exemplo n.º 3
0
        public ActionResult CreateTask(string task, int projectId)
        {
            TaskRepository taskRepo = new TaskRepository();
            ProjectRepository projectRepo = new ProjectRepository();
            List<Project> projects = new List<Project>();

            taskRepo.AddTask(new Task()
            {
                Description = task,
                Priority = 0,
                ProjectId = projectRepo.GetProjects(WebSecurity.CurrentUserId).Find(p => p.Id == projectId).Id,
                Deadline = DateTime.Now,
                IsDone = false
            });

            //Task taskToAdd = taskRepo.GetTasks(projectId).First(t => t.Description.Equals(task));
            //Projects.First(p => p.Id == projectId).Tasks.Add(taskToAdd);
            projects = projectRepo.GetProjects(WebSecurity.CurrentUserId);
            return View("MyToDoList", projects);
        }
Exemplo n.º 4
0
        public ActionResult MarkTaskAsDone(int taskId)
        {
            TaskRepository taskRepo = new TaskRepository();
            ProjectRepository projectRepo = new ProjectRepository();
            //Thread.Sleep(3000);
            taskRepo.SetTaskState(taskId, true);

            List<Project> projects = projectRepo.GetProjects(WebSecurity.CurrentUserId);
            return View("MyToDoList", projects);
        }
Exemplo n.º 5
0
        public ActionResult DeleteTask(int taskId)
        {
            ProjectRepository projectRepo = new ProjectRepository();
            TaskRepository taskRepo = new TaskRepository();

            taskRepo.DeleteTask(taskId);

            List<Project> projects = projectRepo.GetProjects(WebSecurity.CurrentUserId);
            return View("MyToDoList", projects);
        }