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)); }
public JsonResult PopulateTask(string projectType, string prjectId, string taskId) { ToDoTask toDoTask = new ToDoTask(); if (Convert.ToInt32(projectType) == (int)ProjectType.Agile) { toDoTask.SetToDoTaskStrategy(new AgileTask()); } else if (Convert.ToInt32(projectType) == (int)ProjectType.Normal) { toDoTask.SetToDoTaskStrategy(new NormalTask()); } TodoTaskModel todoTaskModel = toDoTask.GetById(new Guid(taskId)); return(Json(todoTaskModel, JsonRequestBehavior.AllowGet)); }
//[Authorize] //[ValidateAntiForgeryToken] public HttpStatusCodeResult DeleteTasks(List <Guid> taskIds) { ToDoTask toDoTask = new ToDoTask(); toDoTask.SetToDoTaskStrategy(new NormalTask()); IEnumerable <TodoTaskModel> _normalTodoTaskModels = toDoTask.DeleteByIds(taskIds); return(_normalTodoTaskModels.Count() == 0 ? new HttpStatusCodeResult(HttpStatusCode.OK, "Record deleted") : new HttpStatusCodeResult(HttpStatusCode.BadRequest, "Bad Request")); }
//[Authorize] //[ValidateAntiForgeryToken] public HttpStatusCodeResult DeleteNormalTask(string taskId) { ToDoTask toDoTask = new ToDoTask(); toDoTask.SetToDoTaskStrategy(new NormalTask()); TodoTaskModel _normalTodoTaskModel = toDoTask.DeleteById(new Guid(taskId)); return(_normalTodoTaskModel == null ? new HttpStatusCodeResult(HttpStatusCode.OK, "Record deleted") : new HttpStatusCodeResult(HttpStatusCode.BadRequest, "Bad Request")); }
//[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)); }
//[Authorize] //[ValidateAntiForgeryToken] public JsonResult UpdateNormalTask(NormalTodoTaskModel todoTaskModel) { todoTaskModel.IsActive = true; todoTaskModel.UpdatedDate = DateTime.Now; //Need to change todoTaskModel.UpdatedBy = ((Models.User)Session["User"]).Id; todoTaskModel.UserId = ((Models.User)Session["User"]).Id; ToDoTask toDoTask = new ToDoTask(); toDoTask.SetToDoTaskStrategy(new NormalTask()); TodoTaskModel _normalTodoTaskModel = toDoTask.Save(todoTaskModel); return(Json(_normalTodoTaskModel, JsonRequestBehavior.AllowGet)); }
public JsonResult InsertNormalTask(NormalTodoTaskModel todoTaskModel) { todoTaskModel.Id = Guid.NewGuid(); todoTaskModel.IsActive = true; todoTaskModel.CreatedDate = DateTime.Now; todoTaskModel.CreatedBy = Guid.Parse(HttpContext.User.Identity.Name.Split('$')[1]); todoTaskModel.UserId = Guid.Parse(HttpContext.User.Identity.Name.Split('$')[1]); todoTaskModel.ProjectId = AppSettings.NormalProjectId; ToDoTask toDoTask = new ToDoTask(); toDoTask.SetToDoTaskStrategy(new NormalTask()); TodoTaskModel normalTodoTaskModel = toDoTask.Save(todoTaskModel); return(Json(normalTodoTaskModel, JsonRequestBehavior.AllowGet)); }
public JsonResult UpdateNormalTask(NormalTodoTaskModel todoTaskModel) { todoTaskModel.IsActive = true; todoTaskModel.UpdatedDate = DateTime.Now; string[] dateParts = todoTaskModel.CreatedDateString.Split('/'); if (dateParts.Length > 0) { todoTaskModel.CreatedDate = Convert.ToDateTime(dateParts[1] + "/" + dateParts[0] + "/" + dateParts[2]); } todoTaskModel.UpdatedBy = Guid.Parse(HttpContext.User.Identity.Name.Split('$')[1]); todoTaskModel.UserId = Guid.Parse(HttpContext.User.Identity.Name.Split('$')[1]); ToDoTask toDoTask = new ToDoTask(); toDoTask.SetToDoTaskStrategy(new NormalTask()); TodoTaskModel normalTodoTaskModel = toDoTask.Save(todoTaskModel); return(Json(normalTodoTaskModel, JsonRequestBehavior.AllowGet)); }