public async Task <IActionResult> RegisterAsync([FromBody] RegisterFoodTableCommand command) { bool validCommand = command.Validate(); if (!validCommand) { return(CreateErrorResponse(command.ValidationResult)); } FoodTable foodTable = new FoodTable( command.Name, command.Description ); await _foodTableRepository.RegisterAsync(foodTable); return(await CommitAsync()); }
public async Task ShouldRegisterFoodTable() { RegisterFoodTableCommand command = new RegisterFoodTableCommand { Name = "Bacon de testes", Description = "Registrando um bacon de testes", }; Mock <IFoodTableRepository> foodTableRepository = new Mock <IFoodTableRepository>(); FoodTableCommandHandler handler = new FoodTableCommandHandler( foodTableRepository.Object, GetIdentityService(null), GetMediator(), GetUnitOfWork(), GetLogger() ); CommandResult commandResult = await handler.Handle(command, default(CancellationToken)); Assert.IsTrue(commandResult.Success); }
public async Task <IActionResult> RegisterAsync([FromBody] RegisterFoodTableCommand command) { return(await CreateCommandResponse(command)); }