public JsonResult UpdateQuickTask(string _todoName, string _todoEndDate, int _todoId, int _projectId, List <int> _todoUsers) { try { var _personId = JsonConvert.DeserializeObject <Person>(HttpContext.Session.GetString("ActivePerson")).Id; _todoUsers.Add(_personId); _todoUsers = _todoUsers.Distinct().ToList(); var QuickTask = new Task() { Title = _todoName, Detail = "", EndDate = DateTime.ParseExact(_todoEndDate, "dd/MM/yyyy", null), Id = _todoId, Status = 1, ProjectId = _projectId }; var result = TaskDB.GetInstance().UpdateTask(QuickTask, _todoUsers); return(Json(result != null)); } catch (System.Exception exc) { throw exc; } }
public JsonResult UpdateTask(string _todoTitle, string _todoDetail, string _todoEndDate, int _todoId, List <int> _todoUsers, List <int> _todoTasks) { try { using (var context = new ProjectManagementEntities()) { var _personId = JsonConvert.DeserializeObject <Person>(HttpContext.Session.GetString("ActivePerson")).Id; _todoUsers.Add(_personId); _todoUsers = _todoUsers.Distinct().ToList(); var projectId = context.Task.FirstOrDefault(x => x.Id == _todoId).ProjectId; var DetailTask = new Task() { Title = _todoTitle, Detail = _todoDetail, EndDate = DateTime.ParseExact(_todoEndDate, "dd/MM/yyyy", null), Id = _todoId, Status = 1, ProjectId = projectId }; var result = TaskDB.GetInstance().UpdateTask(DetailTask, _todoUsers); return(Json(result != null)); } } catch (System.Exception exc) { throw exc; } }
public JsonResult DeleteTask(int _todoId) { try { var result = TaskDB.GetInstance().DeleteTask(_todoId); return(Json(result)); } catch (System.Exception exc) { throw exc; } }
public List <TaskRepo> GetDetailTaskWithCategoryByProjectId(int _id) { try { using (var context = new ProjectManagementEntities()) { var item = TaskDB.GetInstance().GetAllTaskCategoryByProjectId2(_id).ToList(); return(item); } } catch (System.Exception exc) { throw exc; } }
public JsonResult GetTaskById(int _taskId) { try { using (var context = new ProjectManagementEntities()) { var list = TaskDB.GetInstance().GetTaskById(_taskId).ToList(); return(Json(list)); } } catch (System.Exception exc) { throw exc; } }
public List <TaskRepo> GetAllDetailTaskByProjectId() { try { using (var context = new ProjectManagementEntities()) { var _projectId = JsonConvert.DeserializeObject <Project>(HttpContext.Session.GetString("SelectedProject")).Id; var item = TaskDB.GetInstance().GetAllTaskByProjectId2(_projectId).ToList(); return(item); } } catch (System.Exception exc) { throw exc; } }
public List <TaskRepo> GetDetailTaskWithProjectById(int _id) { try { using (var context = new ProjectManagementEntities()) { if (JsonConvert.DeserializeObject <Person>(HttpContext.Session.GetString("ActivePerson")).IsAdmin == 1) { var item = TaskDB.GetInstance().GetAllTaskByProjectId2(_id).ToList(); return(item); } else { var returnList = new List <TaskRepo>(); var _personId = JsonConvert.DeserializeObject <Person>(HttpContext.Session.GetString("ActivePerson")).Id; var userTasksIds = context.TaskUser.Where(x => x.PersonId == _personId).Select(x => x.TaskId).ToList(); var item = context.Task.Where(x => userTasksIds.Contains(x.Id) && x.ProjectId == _id && x.Status > 0 && x.CategoryId == 0).ToList(); foreach (var i in item) { var personIds = context.TaskUser.Where(x => x.TaskId == i.Id).ToList().Select(x => x.PersonId).ToList(); var persons = context.Person.Where(x => personIds.Contains(x.Id)).ToList(); returnList.Add(new TaskRepo() { Detail = i.Detail, Title = i.Title, Id = i.Id, EndDate = i.EndDate, Persons = persons, ProjectId = i.ProjectId, Status = i.Status, StrDate = i.EndDate.ToString("dd/MM/yyyy"), CategoryId = i.CategoryId.ToString() == null ? 0 : i.CategoryId }); } return(returnList); } } } catch (System.Exception exc) { throw exc; } }
public JsonResult SaveCategoryStep(string _todoName, string _todoEndDate, int _projectId, int _catId, List <int> _todoUsers) { try { var _personId = JsonConvert.DeserializeObject <Person>(HttpContext.Session.GetString("ActivePerson")).Id; if (_projectId == 0) { _projectId = JsonConvert.DeserializeObject <Project>(HttpContext.Session.GetString("SelectedProject")).Id; } _todoUsers.Add(_personId); _todoUsers = _todoUsers.Distinct().ToList(); var todo = new Task() { Detail = "", Title = _todoName, ProjectId = _projectId, EndDate = DateTime.ParseExact(_todoEndDate, "dd/MM/yyyy", null), Status = 1, CategoryId = _catId }; var result = TaskDB.GetInstance().SaveTask(todo); foreach (var item in _todoUsers) { var todouser = new TaskUser() { TaskId = result.Id, PersonId = item }; TaskUserDB.GetInstance().SaveTaskUser(todouser); } return(Json(result != null)); } catch (System.Exception exc) { throw exc; } }