public void ShouldRequireTitiel()
        {
            var model  = new CreateNewTodoCommand();
            var result = _validator.TestValidate(model);

            result.ShouldHaveValidationErrorFor(cmd => cmd.Title);
        }
        public async Task <TodoModel> CreateNewTask([FromBody] NewTodoModel model)
        {
            var command = new CreateNewTodoCommand
            {
                Title   = model.Title,
                DueDate = model.DueDate
            };

            return(await Mediator.Send(command));
        }
 public CreateNewTodoCommandHandlerTests()
 {
     _context        = GetDbContext(false);
     _commandHandler = new CreateNewTodoCommandHandler(_context);
     _command        = new CreateNewTodoCommand()
     {
         Id    = Guid.NewGuid(),
         Title = "Test One",
     };
 }
Exemplo n.º 4
0
        public async Task <ActionResult <CommandResult> > Create([FromBody] CreateNewTodoCommand command)
        {
            var resp = await _handler.Handler(command);

            if (resp.Success)
            {
                return(StatusCode(201, resp));
            }

            return(resp.Content == null?StatusCode(404, resp) : BadRequest(resp));
        }