public async Task <ActionResult <TodoItem> > Post([FromBody] TodoItem todo) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var result = await service.AddAsync(todo); return(Ok(result)); }
public async Task add_todo_should_succeed_given_valid_title_and_description_and_priority() { var command = new AddTodo(Guid.Empty, "Some Title", "Some Description", "HIGH"); await _todosService.AddAsync(command); await _todoRepository.Received().AddAsync(Arg.Is <Todo>(x => x.Id == command.Id && x.Title == command.Title && x.Description == command.Description && x.Priority == Priority.HIGH)); }
public async Task <IActionResult> CreateAsync(NewTodoItemModel newTodoItemModel) { var newTodoItemInfo = new NewTodoItemInfo { IsComplete = newTodoItemModel.IsComplete, Name = newTodoItemModel.Name, User = User }; long newlyCreatedEntityId = await todoService.AddAsync(newTodoItemInfo).ConfigureAwait(false); return(Created($"api/todo/{newlyCreatedEntityId}", newlyCreatedEntityId)); }
public async Task <ActionResult <TodoDto> > AddAsync([FromBody] NewTodoDto model) { try { TodoDto result = await _service.AddAsync(model); _logger.LogInformation("'Todo' added."); return(Ok(result)); } catch (Exception ex) { _logger.LogError(ex, "Error when try get selected Todo."); throw; } }
public async Task ShouldCreateTodo() { const string name = "name"; await _service.AddAsync(new TodoCreateRequest { Name = name }); var expected = new Todo { Name = name, }; _context.GetDatabaseValues <Todo>().Single() .Should() .BeEquivalentTo(expected, config => config.Excluding(todo => todo.Id)); }
public async Task <bool> Post([FromBody] Todo todo) { return(await _todoService.AddAsync(todo)); }
public async Task <ActionResult <Todo> > PostTodo(Todo todoDTO) { await _todoService.AddAsync(todoDTO); return(CreatedAtAction(nameof(GetTodo), new { id = todoDTO.Id }, todoDTO)); }
public async Task <TodoDTO> Create([FromBody] TodoCreateRequest request) { return(_mapper.Map <TodoDTO>(await _service.AddAsync(request))); }