예제 #1
0
 public IActionResult DeleteTodo(int id, string searchString, bool?isCompleted, int page, int pageSize)
 {
     try
     {
         todoItemService.DeleteTodoItem(id);
         return(Index(searchString, isCompleted, page, pageSize));
     }
     catch (Exception ex)
     {
         _logger.LogError(ex.Message);
         return(Error());
     }
 }
        public void Delete(int id)
        {
            if (!User.Identity.IsAuthenticated)
            {
                throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.Unauthorized, "Доступ разрешен только для авторизованным пользователям"));
            }
            var item = _todoItemService.GetTodoItemById(id);

            if (item == null)
            {
                throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.NotFound, "Не удалось найти указанный элемент"));
            }
            if (User.Identity.GetUserId() != _todoListService.GetTodoListById(item.TodoListEntityId).ApplicationUserEntityId)
            {
                throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.Forbidden, "Доступ к ресурсу запрещен"));
            }
            _todoItemService.DeleteTodoItem(item);
        }
예제 #3
0
        public async Task <IActionResult> DeleteTodoItem(long id)
        {
            await _todoItemService.DeleteTodoItem(id);

            return(NoContent());
        }
 public async Task <SingleResponseModel <bool> > DeleteTodoItem(int id)
 {
     return(await _todoItemService.DeleteTodoItem(id));
 }
예제 #5
0
        public async Task DeleteTodoItem(long id)
        {
            await _todoItemService.DeleteTodoItem(id);

            Accepted();
        }
예제 #6
0
        public async Task <ActionResult <TodoItem> > DeleteTodoItem(long id)
        {
            var response = await _service.DeleteTodoItem(id);

            return(response);
        }
예제 #7
0
        public async Task DeleteTodoItem(int todoItemId)
        {
            await _todoItemService.DeleteTodoItem(todoItemId);

            await UpdateTodoItems();
        }