Ejemplo n.º 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());
        }
Ejemplo n.º 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());
        }
Ejemplo n.º 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);
        }
        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);
        }
Ejemplo n.º 5
0
 public bool DeleteTodoList([FromServices] ITodoListService todoListService, [FromQuery] long id)
 {
     return(todoListService.DeleteTodoList(id));
 }
Ejemplo n.º 6
0
        public async Task <ActionResult <TodoList> > DeleteTodoList(long id)
        {
            await _todoListService.DeleteTodoList(id);

            return(NoContent());
        }
Ejemplo n.º 7
0
        public async Task DeleteTodoList(long id)
        {
            await _todoService.DeleteTodoList(id);

            Accepted();
        }