コード例 #1
0
        public async Task <IActionResult> DeleteTodo([FromRoute] int id)
        {
            int _userId = Int32.Parse(HttpContext.GetUserId());

            Todos todo = await _todosService.GetTodoByIdAsync(id, _userId);

            if (todo == null)
            {
                return(NotFound(new
                {
                    Error = new[] { "Todo not found." }
                }));
            }

            var resTodo = await _todosService.DeleteTodoAsync(todo);

            return(Ok(resTodo));
        }
コード例 #2
0
        public async Task <IActionResult> Delete(int id)
        {
            var todoItem = await _todosService.GetTodoAsync(id);

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

            var success = await _todosService.DeleteTodoAsync(id);

            if (success)
            {
                return(NoContent());
            }
            else
            {
                return(StatusCode(500));
            }
        }