public async Task <bool> Insert(DTO.Task task, string userName, List <string> errors) { try { task.CreatedBy = userName; task.StatusId = TaskStatusKey.Opened; task.IsActive = true; task.IsTask = true; _unitOfWork.Tasks.Insert(task); var result = await _unitOfWork.CommitAsync() > 0; if (result) { var tmpModule = await _unitOfWork.Modules.GetById(task.ModuleId); await _projectLog.AddLog(new ProjectLog { Content = $"Create task {task.Title}", CreatedBy = userName, CreatedDate = DateTime.Now, ProjectId = tmpModule.ProjectId }, new List <string>()); } return(result); } catch (Exception ex) { errors.Add(ex.Message); return(false); } }
public async Task <DTO.Task> ConvertToTask(DTO.Task task, List <string> errors, string userNameApprove = null) { try { //update request var updateRequest = await _unitOfWork.Tasks.GetById(task.Id); updateRequest.StatusId = RequestStatusKey.Approved; _unitOfWork.Tasks.Update(updateRequest); //clone and insert new task var createNewTask = new DTO.Task(); createNewTask.From = task.From; createNewTask.To = task.To; createNewTask.Priority = task.Priority; createNewTask.Description = task.Description; createNewTask.AssignedTo = task.AssignedTo; createNewTask.Severity = task.Severity; createNewTask.TaskType = task.TaskType; createNewTask.Module = updateRequest.Module; createNewTask.Title = task.Title; createNewTask.IsTask = true; createNewTask.IsActive = true; createNewTask.StatusId = TaskStatusKey.Opened; if (userNameApprove != null) { createNewTask.CreatedBy = userNameApprove; } _unitOfWork.Tasks.Insert(createNewTask); var result = await _unitOfWork.CommitAsync() > 0; if (result) { if (userNameApprove != null) { await _projectLog.AddLog(new ProjectLog { Content = $"Approve request {updateRequest.Title}", CreatedBy = userNameApprove, CreatedDate = DateTime.Now, ProjectId = updateRequest.Module.ProjectId }, new List <string>()); } } return(createNewTask); } catch (Exception ex) { errors.Add(ex.Message); return(null); } }
public async Task <DTO.Task> UpdateRequest(DTO.Task task, List <string> errors, string userName) { try { var updateTask = await _unitOfWork.Tasks.GetById(task.Id); updateTask.From = task.From; updateTask.To = task.To; updateTask.Description = task.Description; updateTask.Severity = task.Severity; updateTask.TaskType = task.TaskType; updateTask.ModuleId = task.ModuleId; updateTask.Title = task.Title; updateTask.IsTask = false; var module = await _unitOfWork.Modules.GetById(task.ModuleId); if (module.Title.Equals(HardFixJobRoleTitle.Watcher)) { updateTask.AssignedTo = module.Project.CreatedBy; } else { updateTask.AssignedTo = module.TeamLead; } _unitOfWork.Tasks.Update(updateTask); var result = await _unitOfWork.CommitAsync() > 0; if (result) { await _projectLog.AddLog(new ProjectLog { Content = $"Update request {task.Title}", CreatedBy = userName, CreatedDate = DateTime.Now, ProjectId = updateTask.Module.ProjectId }, new List <string>()); } return(updateTask); } catch (Exception ex) { errors.Add(ex.Message); return(null); } }
public async Task <bool> InsertRequest(DTO.Task task, string userName, List <string> errors) { try { var module = await _unitOfWork.Modules.GetById(task.ModuleId); if (module.Title.Equals(HardFixJobRoleTitle.Watcher)) { task.AssignedTo = module.Project.CreatedBy; } else { task.AssignedTo = module.TeamLead; } task.CreatedBy = userName; task.StatusId = RequestStatusKey.PendingApproval; task.IsActive = true; task.IsTask = false; _unitOfWork.Tasks.Insert(task); var result = await _unitOfWork.CommitAsync() > 0; if (result) { var tmpModule = await _unitOfWork.Modules.GetById(task.ModuleId); var project = tmpModule.ProjectId; await _projectLog.AddLog(new ProjectLog { Content = $"Create request {task.Title}", CreatedBy = userName, CreatedDate = DateTime.Now, ProjectId = project }, new List <string>()); } return(result); } catch (Exception ex) { errors.Add(ex.Message); return(false); } }
public async Task <DTO.Task> Update(DTO.Task task, List <string> errors, string userName = null) { try { var updateTask = await _unitOfWork.Tasks.GetById(task.Id); updateTask.From = task.From; updateTask.To = task.To; updateTask.Description = task.Description; updateTask.AssignedTo = task.AssignedTo; updateTask.Severity = task.Severity; updateTask.TaskType = task.TaskType; updateTask.ModuleId = task.ModuleId; updateTask.Title = task.Title; updateTask.IsTask = true; if (userName != null) { updateTask.CreatedBy = userName; } _unitOfWork.Tasks.Update(updateTask); var result = await _unitOfWork.CommitAsync() > 0; if (result) { await _projectLog.AddLog(new ProjectLog { Content = $"Update task {task.Title}", CreatedBy = userName, CreatedDate = DateTime.Now, ProjectId = updateTask.Module.ProjectId }, new List <string>()); } return(updateTask); } catch (Exception ex) { errors.Add(ex.Message); return(null); } }