public async Task DeleteAsync(Guid id) { var entity = await _projectTaskRepository.GetByIdAsync(id); if (entity == null) { throw new Exception("Project task not found"); } _projectTaskRepository.Delete(entity); await _projectTaskRepository.SaveAsync(); }
public async Task <Unit> Handle(DeleteTask request, CancellationToken cancellationToken) { var projectTask = await _projectTaskRepository.GetByIdAsync(request.Id, cancellationToken); if (projectTask != null) { _projectTaskRepository.Delete(projectTask); await _projectTaskRepository.UnitOfWork.SaveChangesAsync(cancellationToken); } return(Unit.Value); }
public async Task <Unit> Handle(DeleteProject request, CancellationToken cancellationToken) { var project = await _projectRepository.GetByIdAsync(request.Id, cancellationToken); if (project != null) { var projectTasks = await _projectTaskRepository.GetTasksByProjectIdAsync(project.Id, cancellationToken); foreach (var projectTask in projectTasks) { _projectTaskRepository.Delete(projectTask); } _projectRepository.Delete(project); await _projectRepository.UnitOfWork.SaveChangesAsync(cancellationToken); } return(Unit.Value); }
public IActionResult DeletePost(int id) { repository.Delete(id); return(Redirect("~/")); }
public ActionResult <bool> Delete(int id) => repository.Delete(id);