public void UpdateCustomer(UpdateCustomerInput input) { //We can use Logger, it's defined in ApplicationService base class. Logger.Info("Updating a Customer for input: " + input); //Retrieving a Customer entity with given id using standard Get method of repositories. var customer = _customerRepository.Get(input.CustomerId); customer.Title = input.Title; customer.FirstName = input.FirstName; customer.LastName = input.LastName; customer.Gender = input.Gender; customer.DateOfBirth = input.DateOfBirth; customer.Smoking = input.Smoking; //Updating changed properties of the retrieved Customer entity. if (input.SelectedInsuranceId.HasValue) { customer.SelectedInsurance = _insuranceRepository.Load(input.SelectedInsuranceId.Value); customer.SelectedInsurance.CoverAmount = input.CoverAmount; customer.SelectedInsurance.Premium = input.Premium; } //We even do not call Update method of the repository. //Because an application service method is a 'unit of work' scope as default. //ABP automatically saves all changes when a 'unit of work' scope ends (without any exception). }
public CustomerDto GetCustomer(UpdateCustomerInput input) { var customer = _customerRepository.GetByUserName(input.FirstName, input.LastName, input.Title); return Mapper.Map<CustomerDto>(customer); }