/* * DELETE * api/todolist/:id */ public IActionResult Delete(long id) { var todo = _service.FindTodoListById(id); if (todo == null) { return(NotFound()); } _service.DeleteTodoList(todo); return(new NoContentResult()); }
public async Task <IActionResult> Delete(int id) { var todoList = _todoListService.GetTodoListById(id); if (todoList == null) { return(NotFound()); } await _todoListService.DeleteTodoList(id); return(NoContent()); }
public IActionResult DeleteTodo([FromHeader] int userID, [FromHeader] int todoID) { IActionResult result = null; try { todoListService.DeleteTodoList(userID, todoID); result = Ok(); } catch (Exception e) { //Log result = BadRequest(e); } return(result); }
public void DeleteTodoList(int id) { if (!User.Identity.IsAuthenticated) { throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.Unauthorized, "Доступ разрешен только для авторизованным пользователям")); } var item = _todoListService.GetTodoListById(id); if (item == null) { throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.NotFound, "Не удалось найти указанный элемент")); } if (User.Identity.GetUserId() != item.ApplicationUserEntityId) { throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.Forbidden, "Доступ к ресурсу запрещен")); } _todoListService.DeleteTodoList(item); }
public bool DeleteTodoList([FromServices] ITodoListService todoListService, [FromQuery] long id) { return(todoListService.DeleteTodoList(id)); }
public async Task <ActionResult <TodoList> > DeleteTodoList(long id) { await _todoListService.DeleteTodoList(id); return(NoContent()); }
public async Task DeleteTodoList(long id) { await _todoService.DeleteTodoList(id); Accepted(); }