Beispiel #1
0
        public async Task <IActionResult> Update(int id, CustomerViewModel customer)
        {
            if (id != customer.CustomerId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    var updatedCustomer = new CustomerDto()
                    {
                        CustomerId      = customer.CustomerId,
                        GivenName       = customer.GivenName,
                        FamilyName      = customer.FamilyName,
                        AddressOne      = customer.AddressOne,
                        AddressTwo      = customer.AddressTwo,
                        Town            = customer.Town,
                        State           = customer.State,
                        AreaCode        = customer.AreaCode,
                        Country         = customer.Country,
                        EmailAddress    = customer.EmailAddress,
                        TelephoneNumber = customer.TelephoneNumber
                    };

                    await _customerFacade.PutCustomer(id, updatedCustomer);
                }
                catch (HttpRequestException)
                {
                    _logger.LogWarning("Exception Occured using Customer Facade");
                }
                return(RedirectToAction(nameof(Details)));
            }
            return(View(customer));
        }