Ejemplo 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);
            }
        }
Ejemplo n.º 2
0
 public void AddProject(Project project)
 {
     try
     {
         //using (Context)
         //{
         Context.Projects.Add(project);
         Context.SaveChanges();
         //}
     }
     catch
     {
         throw;
     }
 }