public void UpdateTaskStatus(TaskStatusEditModel statusModel) { TEAM team = _teamRepository.GetTeamById(statusModel.TeamId); TASK_STATUS status = _taskRepository.GetTaskStatusById(statusModel.StatusId); if (team != null && status != null && status.TEAM == team) { status.NAME = statusModel.StatusName; _taskRepository.UpdateTaskStatus(status); } }
public async Task <IActionResult> EditStatus(TaskStatusEditModel editModel) { USER user = await _userRepository.GetUserByContext(HttpContext.User); if (_permissionService.CheckIfUserIsTeamOwner(user, editModel.TeamId)) { if (ModelState.IsValid) { _taskService.UpdateTaskStatus(editModel); return(RedirectToAction("Index", new { teamId = editModel.TeamId })); } else { var model = _taskService.GetTaskStatusForEdit(editModel.StatusId, editModel.TeamId); if (model != null) { return(View(model)); } } } return(RedirectToAction("AccessDenied", "Account")); }
public TaskStatusEditModel GetTaskStatusForEdit(int statusId, int teamId) { TEAM team = _teamRepository.GetTeamById(teamId); TASK_STATUS status = _taskRepository.GetTaskStatusById(statusId); if (team != null && status != null && status.TEAM == team) { TaskStatusEditModel taskStatus = new TaskStatusEditModel { StatusId = status.ID, TeamId = status.TEAM_ID ?? 0, StatusName = status.NAME }; if (status.TEAM_ID != null) { return(taskStatus); } } return(null); }