public async Task <IActionResult> DeleteAsync(int id) { var result = await _todoService.DeleteAsync(id); if (!result.Success) { return(BadRequest(result.Message)); } return(Ok(new { message = "Data Todo List Has Been Deleted" })); }
public async Task <ActionResult <TodoItemDTO> > Delete(long id) { var todo = await _todoService.DeleteAsync(id); if (todo == null) { return(NotFound()); } return(ItemToDTO(todo)); }
public async Task <IActionResult> DeleteTodo(int id) { var found = await _todoService.DeleteAsync(id); if (!found) { return(NotFound()); } return(Ok()); }
public async Task <IActionResult> DeleteAsync(long id) { var deleteTodoItemInfo = new DeleteTodoItemInfo { Id = id, User = User }; await todoService.DeleteAsync(deleteTodoItemInfo).ConfigureAwait(false); return(NoContent()); }
public async Task <ActionResult <bool> > Delete(string TodoId) { try { var check = await _todoService.DeleteAsync(TodoId); return(Task.FromResult(check).Result); }catch (Exception) { return(StatusCode(StatusCodes.Status500InternalServerError, "Error Deleting Data.")); } }
public async Task <IActionResult> DeleteAsync(int id) { var result = await _todoService.DeleteAsync(id); if (!result.Success) { return(BadRequest(result.Message)); } var categoryResource = _mapper.Map <TodoItem, TodoResource>(result.TodoItem); return(Ok(categoryResource)); }
public async Task delete_todo_should_succeed_given_valid_id() { var todo = new Todo(Guid.NewGuid(), "Some Title", "Some Description", Priority.HIGH, State.NEW); _todoRepository.GetAsync(todo.Id).Returns(todo); var command = new DeleteTodo(todo.Id); await _todosService.DeleteAsync(command); await _todoRepository.Received().DeleteAsync(Arg.Is <Todo>(x => x.Id == todo.Id && x.Title == todo.Title && x.Description == todo.Description && x.Priority == todo.Priority && x.State == todo.State && x.CreatedAt == todo.CreatedAt)); }
public async Task <IActionResult> Delete([FromRoute] long id) { if (id <= 0) { return(BadRequest(new ErrorDetailsResponse { Error = "Id should be greater than zero" })); } try { _logger.LogDebug("Deleting todo item '{id}'", id); bool?result = await _todoService.DeleteAsync(id); if (result == true) { _logger.LogDebug("Todo item '{id}' deleted successfully", id); return(NoContent()); } else if (result == null) { _logger.LogDebug("Todo item not found with the given id '{id}'", id); return(NotFound()); } _logger.LogWarning("Didn't get an expected response from service."); } catch (Exception ex) { _logger.LogError(ex, "An unexpected error has occurred"); } return(StatusCode(StatusCodes.Status500InternalServerError, new ErrorDetailsResponse { Error = "An unexpected error has occurred" })); }
public async Task DeleteTodo(int id) { var todo = await todoService.GetAsync <Todo>(x => x.TodoId == id); await todoService.DeleteAsync(todo); }
public async Task <IActionResult> Delete(TodoItemDto itemdto) { Todoitem item = _mapper.Map <Todoitem>(itemdto); return(Ok(await _service.DeleteAsync(item))); }