public UpdateCustomerResponse UpdateCustomer(UpdateCustomerRequest updateCustomerRequest) { try { Customer existingCustomer = _customerRepository.FindBy(updateCustomerRequest.Id); if (existingCustomer != null) { Customer assignableProperties = AssignAvailablePropertiesToDomain(updateCustomerRequest.CustomerProperties); existingCustomer.CustomerAddress = assignableProperties.CustomerAddress; existingCustomer.Name = assignableProperties.Name; ThrowExceptionIfCustomerIsInvalid(existingCustomer); _customerRepository.Update(existingCustomer); UnitOfWork.Commit(); return new UpdateCustomerResponse(); } else { return new UpdateCustomerResponse() { Exception = GetStandardCustomerNotFoundException() }; } } catch (Exception ex) { return new UpdateCustomerResponse() { Exception = ex }; } }
public HttpResponseMessage Put(UpdateCustomerViewModel updateCustomerViewModel) { UpdateCustomerRequest req = new UpdateCustomerRequest(updateCustomerViewModel.Id) { CustomerProperties = new CustomerPropertiesViewModel() { AddressLine1 = updateCustomerViewModel.AddressLine1 ,AddressLine2 = updateCustomerViewModel.AddressLine2 ,City = updateCustomerViewModel.City ,Name = updateCustomerViewModel.Name ,PostalCode = updateCustomerViewModel.PostalCode } }; UpdateCustomerResponse updateCustomerResponse = _customerService.UpdateCustomer(req); return Request.BuildResponse(updateCustomerResponse); }
public UpdateCustomerResponse UpdateCustomer(UpdateCustomerRequest updateCustomerRequest) { return _innerCustomerService.UpdateCustomer(updateCustomerRequest); }