public ActionResult <Task> GetTask(int id) { string userId = User.FindFirst(ClaimTypes.NameIdentifier)?.Value; Task task = _taskRepository.GetBy(id); if (task == null) { return(NotFound()); } return(task); }
public ActionResult <Comment> PostComment(int id, Comment comment) { Task task = _taskRepository.GetBy(id); Employee employee = _employeeRepository.GetBy(comment.Author.Id); comment.Author = employee; task.addComment(comment); _taskRepository.Update(task); _taskRepository.SaveChanges(); return(CreatedAtAction(nameof(GetComment), new { id = comment.Id }, comment)); }
public IActionResult DeleteTask(int id) { Task task = _taskRepository.GetBy(id); if (task == null) { return(NotFound()); } _taskRepository.Delete(task); _taskRepository.SaveChanges(); return(NoContent()); }
public ActionResult <Task> PostTask(int id, Task task) { int userId = Int32.Parse(User.FindFirst(ClaimTypes.NameIdentifier)?.Value); Project project = _projectRepository.GetBy(id); if (userId != project.Manager.Id) { return(StatusCode(403)); } Employee employee = _employeeRepository.GetBy(task.Employee.Id); project.addTaskToProject(task, employee); _projectRepository.Update(project); _projectRepository.SaveChanges(); return(CreatedAtAction(nameof(GetTask), new { id = task.Id }, task)); }
public IActionResult PutTask(int id, Task task) { if (id != task.Id) { return(BadRequest()); } Task updatedTask = _taskRepository.GetBy(task.Id); int userId = Int32.Parse(User.FindFirst(ClaimTypes.NameIdentifier)?.Value); if (updatedTask.Employee.Id != userId) { return(StatusCode(403)); } updatedTask.State = task.State; updatedTask.SpentTime = task.SpentTime; updatedTask.dateOfFinish = DateTime.Now; _taskRepository.Update(updatedTask); _taskRepository.SaveChanges(); return(NoContent()); }
public void Update(Task task) { _context.Update(task); }
public void Delete(Task task) { _tasks.Remove(task); }
public void Add(Task task) { _tasks.Add(task); }