예제 #1
0
        public async Task <IActionResult> DeleteAsync(int id)
        {
            var result = await _todoService.DeleteAsync(id);

            if (!result.Success)
            {
                return(BadRequest(result.Message));
            }
            return(Ok(new { message = "Data Todo List Has Been Deleted" }));
        }
예제 #2
0
        public async Task <ActionResult <TodoItemDTO> > Delete(long id)
        {
            var todo = await _todoService.DeleteAsync(id);

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

            return(ItemToDTO(todo));
        }
        public async Task <IActionResult> DeleteTodo(int id)
        {
            var found = await _todoService.DeleteAsync(id);

            if (!found)
            {
                return(NotFound());
            }

            return(Ok());
        }
예제 #4
0
        public async Task <IActionResult> DeleteAsync(long id)
        {
            var deleteTodoItemInfo = new DeleteTodoItemInfo
            {
                Id   = id,
                User = User
            };

            await todoService.DeleteAsync(deleteTodoItemInfo).ConfigureAwait(false);

            return(NoContent());
        }
예제 #5
0
        public async Task <ActionResult <bool> > Delete(string TodoId)
        {
            try
            {
                var check = await _todoService.DeleteAsync(TodoId);

                return(Task.FromResult(check).Result);
            }catch (Exception)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, "Error Deleting Data."));
            }
        }
예제 #6
0
        public async Task <IActionResult> DeleteAsync(int id)
        {
            var result = await _todoService.DeleteAsync(id);

            if (!result.Success)
            {
                return(BadRequest(result.Message));
            }

            var categoryResource = _mapper.Map <TodoItem, TodoResource>(result.TodoItem);

            return(Ok(categoryResource));
        }
        public async Task delete_todo_should_succeed_given_valid_id()
        {
            var todo = new Todo(Guid.NewGuid(), "Some Title", "Some Description", Priority.HIGH, State.NEW);

            _todoRepository.GetAsync(todo.Id).Returns(todo);

            var command = new DeleteTodo(todo.Id);

            await _todosService.DeleteAsync(command);

            await _todoRepository.Received().DeleteAsync(Arg.Is <Todo>(x =>
                                                                       x.Id == todo.Id &&
                                                                       x.Title == todo.Title &&
                                                                       x.Description == todo.Description &&
                                                                       x.Priority == todo.Priority &&
                                                                       x.State == todo.State &&
                                                                       x.CreatedAt == todo.CreatedAt));
        }
예제 #8
0
        public async Task <IActionResult> Delete([FromRoute] long id)
        {
            if (id <= 0)
            {
                return(BadRequest(new ErrorDetailsResponse
                {
                    Error = "Id should be greater than zero"
                }));
            }

            try
            {
                _logger.LogDebug("Deleting todo item '{id}'", id);
                bool?result = await _todoService.DeleteAsync(id);

                if (result == true)
                {
                    _logger.LogDebug("Todo item '{id}' deleted successfully", id);
                    return(NoContent());
                }
                else if (result == null)
                {
                    _logger.LogDebug("Todo item not found with the given id '{id}'", id);
                    return(NotFound());
                }
                _logger.LogWarning("Didn't get an expected response from service.");
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, "An unexpected error has occurred");
            }
            return(StatusCode(StatusCodes.Status500InternalServerError, new ErrorDetailsResponse
            {
                Error = "An unexpected error has occurred"
            }));
        }
예제 #9
0
        public async Task DeleteTodo(int id)
        {
            var todo = await todoService.GetAsync <Todo>(x => x.TodoId == id);

            await todoService.DeleteAsync(todo);
        }
예제 #10
0
        public async Task <IActionResult> Delete(TodoItemDto itemdto)
        {
            Todoitem item = _mapper.Map <Todoitem>(itemdto);

            return(Ok(await _service.DeleteAsync(item)));
        }