/// <summary> /// Update Customer /// </summary> /// <param name="customerID"></param> /// <param name="customerCode"></param> /// <param name="companyName"></param> /// <param name="address"></param> /// <param name="city"></param> /// <param name="region"></param> /// <param name="postalCode"></param> /// <param name="country"></param> /// <param name="phoneNumber"></param> /// <param name="webSiteUrl"></param> /// <param name="transaction"></param> /// <returns></returns> public Customer UpdateCustomer(Guid customerID, string customerCode, string companyName, string address, string city, string region, string postalCode, string country, string phoneNumber, string webSiteUrl, out TransactionalInformation transaction) { transaction = new TransactionalInformation(); CustomersBusinessRules customersBusinessRules = new CustomersBusinessRules(); Customer customer = new Customer(); try { customersDataService.CreateSession(); customer = customersDataService.GetCustomer(customerID); customer.CustomerCode = customerCode; customer.CompanyName = companyName; customer.Address = address; customer.City = city; customer.Region = region; customer.PostalCode = postalCode; customer.Country = country; customer.PhoneNumber = phoneNumber; customer.WebSiteUrl = webSiteUrl; customersBusinessRules.ValidateCustomerUpdate(customer, customersDataService); if (customersBusinessRules.ValidationStatus == true) { customersDataService.BeginTransaction(); customersDataService.UpdateCustomer(customer); customersDataService.CommitTransaction(true); transaction.ReturnStatus = true; transaction.ReturnMessage.Add("Customer successfully updated at " + customer.DateUpdated.ToString()); } else { transaction.ReturnStatus = customersBusinessRules.ValidationStatus; transaction.ReturnMessage = customersBusinessRules.ValidationMessage; transaction.ValidationErrors = customersBusinessRules.ValidationErrors; } } catch (Exception ex) { transaction.ReturnMessage = new List <string>(); string errorMessage = ex.Message; transaction.ReturnStatus = false; transaction.ReturnMessage.Add(errorMessage); } finally { customersDataService.CloseSession(); } return(customer); }
/// <summary> /// Update Customer /// </summary> /// <param name="customerID"></param> /// <param name="customerCode"></param> /// <param name="companyName"></param> /// <param name="address"></param> /// <param name="city"></param> /// <param name="region"></param> /// <param name="postalCode"></param> /// <param name="country"></param> /// <param name="phoneNumber"></param> /// <param name="webSiteUrl"></param> /// <param name="transaction"></param> /// <returns></returns> public Customer UpdateCustomer(Guid customerID, string customerCode, string companyName, string address, string city, string region, string postalCode, string country, string phoneNumber, string webSiteUrl, out TransactionalInformation transaction) { transaction = new TransactionalInformation(); CustomersBusinessRules customersBusinessRules = new CustomersBusinessRules(); Customer customer = new Customer(); try { customersDataService.CreateSession(); customer = customersDataService.GetCustomer(customerID); customer.CustomerCode = customerCode; customer.CompanyName = companyName; customer.Address = address; customer.City = city; customer.Region = region; customer.PostalCode = postalCode; customer.Country = country; customer.PhoneNumber = phoneNumber; customer.WebSiteUrl = webSiteUrl; customersBusinessRules.ValidateCustomerUpdate(customer, customersDataService); if (customersBusinessRules.ValidationStatus == true) { customersDataService.BeginTransaction(); customersDataService.UpdateCustomer(customer); customersDataService.CommitTransaction(true); transaction.ReturnStatus = true; transaction.ReturnMessage.Add("Customer successfully updated at " + customer.DateUpdated.ToString()); } else { transaction.ReturnStatus = customersBusinessRules.ValidationStatus; transaction.ReturnMessage = customersBusinessRules.ValidationMessage; transaction.ValidationErrors = customersBusinessRules.ValidationErrors; } } catch (Exception ex) { transaction.ReturnMessage = new List<string>(); string errorMessage = ex.Message; transaction.ReturnStatus = false; transaction.ReturnMessage.Add(errorMessage); } finally { customersDataService.CloseSession(); } return customer; }