public async Task <IActionResult> DeleteStage(long?Id, long?IdOwner) //Delete Stage { bool userExists = CheckUser(); if (!userExists) { return(RedirectToAction("Signin", "Account")); } if (Id == null || IdOwner == null) { return(NotFound()); } try { StageTask stageTask; await Task.Run(() => { stageTask = new StageUtils().GetOneStage(_context, (long)Id); _context.StageTasks.Remove(stageTask); }); await _context.SaveChangesAsync(); return(RedirectToAction("Details", new { id = IdOwner })); } catch { return(NotFound()); } }
public IList <SprintM> GetAll(Guid project_id) { try { var result = _sprint.Where(s => s.ProjectId.Equals(project_id)).OrderByDescending(s => s.No) .Select(s => new SprintM { EndDate = s.EndDate, Id = s.Id, No = s.No, StartDate = s.StartDate, Stage = new Stage { StageCode = s.StageCode, Name = s.StageCode.ToString() }, NextStage = new Stage { StageCode = StageUtils.GetNextStage(s.StageCode), Name = StageUtils.GetNextStage(s.StageCode).ToString() } }).ToList(); foreach (var sprint in result) { sprint.IsRequireApproval = _approval.Any(a => a.SprintId.Equals(sprint.Id) && a.StageCode.Equals(sprint.NextStage.StageCode)); } return(result); } catch (Exception e) { throw e is RequestException ? e : _errorHandler.WriteLog("An error occurred while get all sprint!", e, DateTime.Now, "Server", "Service_Sprint_GetAll"); } }
public IList <ProjectLastSprintM> GetAll(Guid user_id) { try { var result = _permission.Where(p => p.Project.Permissions.Any(p => p.UserId.Equals(user_id)) && p.RoleId.Equals(RoleID.Admin)) .Select(p => new ProjectLastSprintM { CreatedDate = p.Project.CreatedDate, EndDate = p.Project.EndDate, Id = p.Project.Id, Name = p.Project.Name, ProjectType = new ProjectTypeM { Id = p.Project.ProjectType.Id, Name = p.Project.ProjectType.Name }, StartDate = p.Project.StartDate, Owner = new UserM { Id = p.User.Id, Username = p.User.Username }, TotalSprint = p.Project.Sprints.Count(), LastSprint = p.Project.Sprints.OrderByDescending(s => s.No).Select(s => new SprintM { No = s.No, EndDate = s.EndDate, Id = s.Id, NextStage = new Models.Nococid.Stage { Name = StageUtils.GetNextStage(s.StageCode).ToString(), StageCode = StageUtils.GetNextStage(s.StageCode) }, Stage = new Models.Nococid.Stage { StageCode = s.StageCode, Name = s.StageCode.ToString() }, StartDate = s.StartDate }).FirstOrDefault() }).ToList(); foreach (var project in result) { if (project.LastSprint != null) { project.LastSprint.IsRequireApproval = _approval.Any(a => a.SprintId.Equals(project.LastSprint.Id) && a.StageCode.Equals(project.LastSprint.NextStage.StageCode)); } } return(result); } catch (Exception e) { throw e is RequestException ? e : _errorHandler.WriteLog("An error occurred while get all project!", e, DateTime.Now, "Server", "Service_Project_GetAll"); } }
public SprintTasksM GetAllMyTask(Guid sprint_id, Guid user_id) { try { var result = _sprint.Where(s => s.Id.Equals(sprint_id)) .Select(s => new SprintTasksM { Id = s.Id, NextStage = new Models.Nococid.Stage { Name = StageUtils.GetNextStage(s.StageCode).ToString(), StageCode = StageUtils.GetNextStage(s.StageCode) }, Stage = new Models.Nococid.Stage { StageCode = s.StageCode, Name = s.StageCode.ToString() }, No = s.No, StartDate = s.StartDate, EndDate = s.EndDate, Tasks = s.StageCode.Equals(StageEnum.Planning) == true ? null : s.Tasks.Where(t => t.UserId.Equals(user_id)).Select(t => new TaskDM { AssignedUser = new UserM { Id = t.User.Id, Username = t.User.Username }, Id = t.Id, Detail = t.Detail, Name = t.Name, Side = t.Side, Status = t.Status }).ToList() }).FirstOrDefault(); if (result != null) { result.IsRequireApproval = _approval.Any(a => a.SprintId.Equals(result.Id) && a.StageCode.Equals(result.NextStage.StageCode)); } return(result); } catch (Exception e) { throw e is RequestException ? e : _errorHandler.WriteLog("An error occurred while get all my tasks!", e, DateTime.Now, "Server", "Service_Task_GetAll"); } }
public SprintM GoNextStage(Guid project_id, Guid sprint_id) { try { Sprint sprint = _sprint.GetOne(s => s.Id.Equals(sprint_id) && s.ProjectId.Equals(project_id)); if (sprint == null) { throw NotFound(sprint_id, "sprint id"); } StageEnum next_stage = StageUtils.GetNextStage(sprint.StageCode); if (!_approval.Any(a => a.SprintId.Equals(sprint_id) && a.StageCode.Equals(next_stage))) { throw BadRequest("The next stage will be automatically approved. This action should not be performed!"); } sprint.StageCode = next_stage; SaveChanges(); next_stage = StageUtils.GetNextStage(next_stage); return(new SprintM { EndDate = sprint.EndDate, Id = sprint.Id, No = sprint.No, StartDate = sprint.StartDate, Stage = new Stage { StageCode = sprint.StageCode, Name = sprint.StageCode.ToString() }, NextStage = new Stage { StageCode = next_stage, Name = next_stage.ToString() }, IsRequireApproval = _approval.Any(a => a.SprintId.Equals(sprint.Id) && a.StageCode.Equals(next_stage)) }); } catch (Exception e) { throw e is RequestException ? e : _errorHandler.WriteLog("An error occurred while go to next stage of a sprint!", e, DateTime.Now, "Server", "Service_Sprint_GoNextStage"); } }
public void GoNextStage(Guid sprint_id) { try { Sprint sprint = _sprint.GetOne(s => s.Id.Equals(sprint_id)); if (sprint == null) { throw NotFound(sprint_id, "sprint id"); } StageEnum next_stage = StageUtils.GetNextStage(sprint.StageCode); if (!_approval.Any(a => a.SprintId.Equals(sprint_id) && a.StageCode.Equals(next_stage))) { sprint.StageCode = next_stage; SaveChanges(); } } catch (Exception e) { throw e is RequestException ? e : _errorHandler.WriteLog("An error occurred while go to next stage of a sprint!", e, DateTime.Now, "Server", "Service_Sprint_GoNextStage"); } }
public async Task <IActionResult> Index(long?Id, long?IdOwner, string name) //Show collection Nodes for one StageTask { bool userExists = CheckUser(); if (!userExists) { return(RedirectToAction("Signin", "Account")); } if (Id == null || IdOwner == null || name == null) { return(NotFound()); } StageTask stage = null; try { await Task.Run(() => { stage = new StageUtils().GetOneStage(_context, (long)Id); }); } catch { return(NotFound()); } if (stage == null) { return(NotFound()); } if (name.Length < 6) { return(NotFound()); } string firstFiveChar = new string(name.Take(5).ToArray()); if ("Stage".CompareTo(firstFiveChar) != 0) { return(NotFound()); } string numbers = new string(name.Skip(5).ToArray()); long number; try { number = Int64.Parse(numbers); } catch (FormatException) { return(NotFound()); } int count_stage; try { count_stage = _context.StageTasks.Where(s => s.IdOwner == IdOwner).Count(); } catch (Exception) { return(NotFound()); } if (number > count_stage) { return(NotFound()); } int sizePage = 10; int count; try { count = _context.NodeStages.Where(n => n.IdOwner == Id).Count(); } catch (Exception) { return(NotFound()); } int totalPages; int lastPageSize; try { totalPages = (int)Math.Ceiling((count / (double)sizePage)); lastPageSize = count % sizePage; } catch (Exception) { return(NotFound()); } ViewBag.NameStage = name; ViewBag.IdOwner = IdOwner; ViewBag.IdStage = Id; string nameTask = null; try { nameTask = await _context.BoardTasks.Where(t => t.Id == IdOwner).Select(t => t.NameTask).FirstOrDefaultAsync(); } catch (Exception) { return(NotFound()); } if (nameTask == null) { return(NotFound()); } ViewBag.NameTask = nameTask; ViewBag.TotalPages = totalPages; var list_node = await _context.NodeStages.Where(n => n.IdOwner == Id).Skip((1 - 1) * sizePage).Take(sizePage).ToListAsync(); return(View(list_node)); }
// GET: BoardTasks/Details/5 public async Task <IActionResult> Details(long?id) //Show one BoardTask and collection StageTasks { bool userExists = CheckUser(); if (!userExists) { return(RedirectToAction("Signin", "Account")); } if (id == null) { return(NotFound()); } BoardTask boardTask = null; try { await Task.Run(() => { boardTask = new BoardTaskUtils().GetBoardTask(_context, (long)id); }); } catch (Exception) { return(NotFound()); } if (boardTask != null) { BoardViewModel board = new BoardViewModel(); board.Content = boardTask.ContentTask; board.Name = boardTask.NameTask; board.Id = boardTask.Id; board.DateCreated = boardTask.DateCreated; board.DateFinished = boardTask.DateFinished; IEnumerable <StageTask> taskstages = null; try { await Task.Run(() => { taskstages = new StageUtils().GetStagesForTask(_context, boardTask.Id); }); } catch (Exception) { return(NotFound()); } BoardStageViewModel boardStageView = new BoardStageViewModel { BoardView = board, StageTasks = taskstages }; return(View(boardStageView)); } else { return(NotFound()); } }