Esempio n. 1
0
        public async Task <IActionResult> CreateCustomer([FromBody] CustomerPresenter model, CancellationToken cancellationToken = default)
        {
            var customer   = model.ToDomain();
            var customerId = await customersRepository.Save(customer, cancellationToken);

            model.Id = customerId.Value;

            return(AcceptedAtAction("Get", new { id = customerId.Value }, model));
        }
Esempio n. 2
0
        public async Task <IActionResult> UpdateCustomer([FromBody] CustomerPresenter model, CancellationToken cancellationToken = default)
        {
            if (!await customersRepository.Exists(model.Id, cancellationToken))
            {
                return(NotFound());
            }

            var customer = model.ToDomain();
            await customersRepository.Save(customer, cancellationToken);

            return(AcceptedAtAction("Get", new { id = customer.Id.Value }, model));
        }