Esempio n. 1
0
        public ActionResult GetAll(int?page)
        {
            ProjectManager projectManager = new ProjectManager();

            //To populate hard caded project data
            projectManager.SaveProject();

            ToDoTaskComplexType toDoTaskComplexType = new ToDoTaskComplexType();

            toDoTaskComplexType.Project =
                projectManager.GetProjects().Where(x => x.Type == (int)ProjectType.Normal).FirstOrDefault();

            ToDoTask toDoList = new ToDoTask();

            if (toDoTaskComplexType.Project.Type == (int)ProjectType.Agile)
            {
                toDoList.SetToDoTaskStrategy(new AgileTask());
            }
            else if (toDoTaskComplexType.Project.Type == (int)ProjectType.Normal)
            {
                toDoList.SetToDoTaskStrategy(new NormalTask());
            }

            int pageSize = Convert.ToInt32(ConfigurationManager.AppSettings["PageSize"]);

            toDoTaskComplexType.TodoTasks =
                toDoList.GetAll(toDoTaskComplexType.Project.Id).
                Where(x => x.UserId == Guid.Parse(HttpContext.User.Identity.Name.Split('$')[1])).
                OrderByDescending(x => x.UpdatedDate == DateTime.MinValue ? x.CreatedDate : x.UpdatedDate).ToList();

            toDoTaskComplexType.TodoTaskCount = toDoTaskComplexType.TodoTasks.Count;

            toDoTaskComplexType.TodoTasks = toDoTaskComplexType.TodoTasks.Skip((page ?? 0) * pageSize).Take(pageSize).ToList();

            toDoTaskComplexType.TaskStatus =
                from TaskStatus status in Enum.GetValues(typeof(TaskStatus))
                select new SelectListItem {
                Value = Convert.ToInt32(status).ToString(), Text = status.ToString()
            };

            toDoTaskComplexType.TaskPriorities =
                from TaskPriority priority in Enum.GetValues(typeof(TaskPriority))
                select new SelectListItem {
                Value = Convert.ToInt32(priority).ToString(), Text = priority.ToString()
            };

            return(View(toDoTaskComplexType));
        }
Esempio n. 2
0
        //[Authorize(Roles = "Manager, Developer, Tester")]
        public ActionResult AllTasks()
        {
            ProjectManager _projectManager = new ProjectManager();

            //To populate hard caded project data
            //_projectManager.SaveProject();

            ToDoTaskComplexType _toDoTaskComplexType = new ToDoTaskComplexType();

            //Loads normal/waterfall model's project only.
            _toDoTaskComplexType.Project = _projectManager.GetProjects().Where(x => x.Type == (int)ProjectType.Normal).FirstOrDefault();

            ToDoTask _toDoTask = new ToDoTask();

            if (_toDoTaskComplexType.Project.Type == (int)ProjectType.Agile)
            {
                _toDoTask.SetToDoTaskStrategy(new AgileTask());
            }
            else if (_toDoTaskComplexType.Project.Type == (int)ProjectType.Normal)
            {
                _toDoTask.SetToDoTaskStrategy(new NormalTask());
            }

            _toDoTaskComplexType.TodoTasks = _toDoTask.GetAll(_toDoTaskComplexType.Project.Id).Where(x => x.UserId == ((Models.User)Session["User"]).Id);

            _toDoTaskComplexType.TaskStatuses = from TaskStatus status in Enum.GetValues(typeof(TaskStatus))
                                                select new SelectListItem {
                Value = Convert.ToInt32(status).ToString(), Text = status.ToString()
            };

            _toDoTaskComplexType.TaskPriorities = from TaskPriority priority in Enum.GetValues(typeof(TaskPriority))
                                                  select new SelectListItem {
                Value = Convert.ToInt32(priority).ToString(), Text = priority.ToString()
            };

            return(View(_toDoTaskComplexType));
        }