public async Task <BaseResponseModel> DeleteAsync(Guid id, CancellationToken cancellationToken = default) { var todoItem = await _todoItemRepository.GetFirstAsync(ti => ti.Id == id); return(new BaseResponseModel { Id = (await _todoItemRepository.DeleteAsync(todoItem)).Id }); }
public async Task <int> DeleteTask(int id) { var todoItem = await _repository.DbContext.TodoItems.FindAsync(id); if (todoItem is null) { return(0); } return(await _repository.DeleteAsync(todoItem)); }
public async Task <IActionResult> Delete(long id) { try { await repo.DeleteAsync(id); return(NoContent()); } catch (Exception ex) { logger.LogError(ex, "Can not delete todo items."); return(StatusCode(500)); } }
public async Task <IActionResult> DeleteTodoItem(int id) { var todoItem = await _todoItemRepository.GetAsync(id); if (todoItem == null) { return(NotFound()); } await _todoItemRepository.DeleteAsync(todoItem); return(NoContent()); }
public async Task <BaseResponseModel> DeleteAsync(Guid id) { var todoItem = await _todoItemRepository.GetFirstAsync(ti => ti.Id == id); if (todoItem == null) { throw new NotFoundException("Todo item does not exist anymore"); } return(new BaseResponseModel { Id = (await _todoItemRepository.DeleteAsync(todoItem)).Id }); }
public async Task HandleAsync(DeleteTodo command, ICorrelationContext context) { if (!await _repository.ExistsAsync(command.Id)) { //throw new MinotaurException("todo_item_not_found", // $"TodoItem with id: '{command.Id}' was not found."); await _busPublisher.PublishAsync( new DeleteTodoItemRejected(command.Id, "todo_item_does_not_exist", $"TodoItem with id: '{command.Id}' was not found."), context); return; } await _repository.DeleteAsync(command.Id); await _busPublisher.PublishAsync(new TodoItemDeleted(command.Id), context); }
public async Task <ActionResult> RemoveItem(string toDoId) { try { var toDoToUpdate = await _repo.GetByIdAsync(toDoId); if (toDoToUpdate == null) { return(NotFound(toDoId)); } await _repo.DeleteAsync(toDoToUpdate); return(NoContent()); } catch (EntityNotFoundException) { return(NotFound(toDoId)); } }
private static void DeleteItems(ITodoItemRepository todoItemRepository, IEnumerable <TodoItem> selectedItems) { Task.WaitAll(selectedItems.Select(item => todoItemRepository.DeleteAsync(item)).ToArray()); Console.Clear(); }
public async Task DeleteAsync(int id) { await _repository.DeleteAsync(x => x.Id.Equals(id)); }
public async Task DeleteAsync(Guid id) { await _todoItemRepository.DeleteAsync(id); }