public async Task <IActionResult> UpdateCustomer([FromBody] Customer customer, [FromServices] UpdateCustomerCommand command)
        {
            if (customer == null)
            {
                throw new MissingRequestBodyException();
            }

            if (!TryValidateModel(customer))
            {
                return(new UnprocessableEntityResult());
            }

            await command.Execute(customer);

            return(Ok());
        }
Exemplo n.º 2
0
        public async Task ShouldUpdateCustomerInDatabase()
        {
            var command = new UpdateCustomerCommand(_context);

            var model = new UpdateCustomerModel {
                CustomerId  = "JASON",
                CompanyName = "Jason Inc",
                ContactName = "Jason Taylor"
            };

            await command.Execute(model);

            var entity = await _context.Customers.FindAsync("JASON");

            Assert.Equal("Jason Inc", entity.CompanyName);
        }