コード例 #1
0
        /*
         * 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());
        }
コード例 #2
0
        public async Task <IActionResult> Delete(int id)
        {
            var todoList = _todoListService.GetTodoListById(id);

            if (todoList == null)
            {
                return(NotFound());
            }

            await _todoListService.DeleteTodoList(id);

            return(NoContent());
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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);
        }
コード例 #5
0
 public bool DeleteTodoList([FromServices] ITodoListService todoListService, [FromQuery] long id)
 {
     return(todoListService.DeleteTodoList(id));
 }
コード例 #6
0
        public async Task <ActionResult <TodoList> > DeleteTodoList(long id)
        {
            await _todoListService.DeleteTodoList(id);

            return(NoContent());
        }
コード例 #7
0
        public async Task DeleteTodoList(long id)
        {
            await _todoService.DeleteTodoList(id);

            Accepted();
        }