public void AddCustomer(Customer customer) { try { _customerRepository.Add(customer); _uow.Save(); } catch (Exception ex) { throw new Exception("Failed adding the customer", ex); } }
public void UpdateCustomerInfo(Customer customer) { }
private void AddCustomer(string customerAlias, string email, int profileId) { var customer = new Customer(); if (ModelState.IsValid) { customer.CustomerAlias = customerAlias; customer.UserProfileId = profileId; customer.IsActive = true; customer.ContactEmail = email; _customerService.AddCustomer(customer); } }
public void UpdateCustomerInfo(Customer customer, CustomerAddress billingAddress, CustomerAddress shippingAddress) { try { var profileId = UserManager.FindById(User.Identity.GetUserId()).UserProfile.Id; var custo = _customerService.FindCustomerBy(profileId); custo.CustomerAlias = customer.CustomerAlias; custo.BillingAddress = customer.BillingAddress; custo.ShippingAddress = customer.ShippingAddress; custo.ContactEmail = customer.ContactEmail; custo.ContactTel = customer.ContactTel; //_customerService.UpdateCustomerInfo(custo); //new code: customer address var billingAddr = _customerService.FindCustomerAddress(custo.Id, 1); //get billing address var shippingAddr = _customerService.FindCustomerAddress(custo.Id, 2); //get shipping address if (billingAddr != null) { billingAddr.AddressStreet = billingAddress.AddressStreet; billingAddr.AddressCity = billingAddress.AddressCity; billingAddr.AddressProState = billingAddress.AddressProState; billingAddr.AddressPostZipCode = billingAddress.AddressPostZipCode; billingAddr.AddressType = billingAddress.AddressType; billingAddr.CustomerId = customer.Id; billingAddress.AddressCountry = "Canada"; } if (shippingAddr != null) { shippingAddr.AddressStreet = shippingAddress.AddressStreet; shippingAddr.AddressCity = shippingAddress.AddressCity; shippingAddr.AddressProState = shippingAddress.AddressProState; shippingAddr.AddressPostZipCode = shippingAddress.AddressPostZipCode; shippingAddr.AddressType = shippingAddress.AddressType; shippingAddr.CustomerId = customer.Id; shippingAddr.AddressCountry = "Canada"; } _customerService.UpdateCustomerInfo(custo, billingAddress, shippingAddress); } catch (Exception) { throw; } }
public void AddCustomer(string customerAlias) { var customer = new Customer(); if (ModelState.IsValid) { customer.CustomerAlias = customerAlias; customer.IsActive = true; _customerService.AddCustomer(customer); } }
public void UpdateCustomerInfo(Customer customer) { try { _customerRepository.Update(customer); _uow.Save(); } catch (Exception ex) { throw new Exception("Failed updating the customer", ex); } }
public void UpdateCustomerInfo(Customer customer, CustomerAddress billingAddress, CustomerAddress shippingAddress) { try { _customerRepository.Update(customer); var bAddress = _customerAddressRepository.GetAll().FirstOrDefault(c => c.CustomerId == customer.Id && c.AddressType == 1); if (bAddress != null) { //_custRepository.UpdateCusotmerAddress(customer.Id, billingAddress); bAddress.AddressCity = billingAddress.AddressCity; bAddress.AddressStreet = billingAddress.AddressStreet; bAddress.AddressProState = billingAddress.AddressProState; bAddress.AddressPostZipCode = billingAddress.AddressPostZipCode; bAddress.AddressCountry = billingAddress.AddressCountry; _customerAddressRepository.Update(bAddress); } else { //_custRepository.AddCusotmerAddress(customer.Id, billingAddress); if (billingAddress.AddressStreet != null && billingAddress.AddressCity != null && billingAddress.AddressProState != null && billingAddress.AddressPostZipCode != null) { _customerAddressRepository.Add(billingAddress); } } var sAddress = _customerAddressRepository.GetAll().FirstOrDefault(c => c.CustomerId == customer.Id && c.AddressType == 2); if (sAddress != null) { //_custRepository.UpdateCusotmerAddress(customer.Id, billingAddress); sAddress.AddressCity = shippingAddress.AddressCity; sAddress.AddressStreet = shippingAddress.AddressStreet; sAddress.AddressProState = shippingAddress.AddressProState; sAddress.AddressPostZipCode = shippingAddress.AddressPostZipCode; sAddress.AddressCountry = shippingAddress.AddressCountry; _customerAddressRepository.Update(sAddress); } else { //_custRepository.AddCusotmerAddress(customer.Id, shippingAddress); if (shippingAddress.AddressStreet != null && shippingAddress.AddressCity != null && shippingAddress.AddressProState != null && shippingAddress.AddressPostZipCode != null) { _customerAddressRepository.Add(shippingAddress); } } _uow.Save(); } catch (Exception ex) { throw new Exception("Failed updating the customer", ex); } }