Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static bool UpdateFromAPIMerchant(this Database.Merchant dbmerchant, Merchant merchant)
- {
- bool updated = false;
- if (merchant.Enabled != null && dbmerchant.Enabled != merchant.Enabled)
- {
- dbmerchant.Enabled = (bool) merchant.Enabled;
- updated = true;
- }
- if (!string.IsNullOrEmpty(merchant.Name) && dbmerchant.Name != merchant.Name)
- {
- dbmerchant.Name = merchant.Name;
- updated = true;
- }
- if (!string.IsNullOrEmpty(merchant.Street) && dbmerchant.Street != merchant.Street)
- {
- dbmerchant.Street = merchant.Street;
- updated = true;
- }
- if (!string.IsNullOrEmpty(merchant.City) && dbmerchant.City != merchant.City)
- {
- dbmerchant.City = merchant.City;
- updated = true;
- }
- if (!string.IsNullOrEmpty(merchant.Country) && dbmerchant.Country != merchant.Country)
- {
- dbmerchant.Country = merchant.Country;
- updated = true;
- }
- if (!string.IsNullOrEmpty(merchant.PostalCode) && dbmerchant.PostalCode != merchant.PostalCode)
- {
- merchant.ValidatePostalCode();
- dbmerchant.PostalCode = merchant.PostalCode;
- updated = true;
- }
- if (!string.IsNullOrEmpty(merchant.TelephoneNumber) &&
- dbmerchant.TelephoneNumber != merchant.TelephoneNumber)
- {
- merchant.ValidateTelephoneNumber();
- dbmerchant.TelephoneNumber = merchant.TelephoneNumber;
- updated = true;
- }
- if (!string.IsNullOrEmpty(merchant.MasterCardAssignedID) &&
- dbmerchant.MasterCardAssignedId != merchant.MasterCardAssignedID)
- {
- dbmerchant.MasterCardAssignedId = merchant.MasterCardAssignedID;
- updated = true;
- }
- //update merchant fields relating to American Express (AMEX)
- if (merchant.AMEX != null)
- {
- if (dbmerchant.AMEX == null)
- {
- dbmerchant.AMEX = new Database.Merchant.AMEXFields {Created = DateTime.Now.ToUniversalTime()};
- merchant.ValidateAMEXFields();
- }
- if (dbmerchant.AMEX.Enabled != merchant.AMEX.Enabled)
- {
- dbmerchant.AMEX.Enabled = merchant.AMEX.Enabled;
- updated = true;
- }
- if (dbmerchant.AMEX.TransactionSourceType != merchant.AMEX.TransactionSourceType)
- {
- dbmerchant.AMEX.TransactionSourceType = merchant.AMEX.TransactionSourceType;
- updated = true;
- }
- if (!string.IsNullOrEmpty(merchant.AMEX.AuthorizedSignerFirstName) && dbmerchant.AMEX.AuthorizedSignerFirstName != merchant.AMEX.AuthorizedSignerFirstName)
- {
- dbmerchant.AMEX.AuthorizedSignerFirstName = merchant.AMEX.AuthorizedSignerFirstName;
- updated = true;
- }
- if (!string.IsNullOrEmpty(merchant.AMEX.AuthorizedSignerLastName) && dbmerchant.AMEX.AuthorizedSignerLastName != merchant.AMEX.AuthorizedSignerLastName)
- {
- dbmerchant.AMEX.AuthorizedSignerLastName = merchant.AMEX.AuthorizedSignerLastName;
- updated = true;
- }
- if (!string.IsNullOrEmpty(merchant.AMEX.AuthorizedSignerTitle) && dbmerchant.AMEX.AuthorizedSignerTitle != merchant.AMEX.AuthorizedSignerTitle)
- {
- dbmerchant.AMEX.AuthorizedSignerTitle = merchant.AMEX.AuthorizedSignerTitle;
- updated = true;
- }
- if (!string.IsNullOrEmpty(merchant.AMEX.SellerEmailAddress) && dbmerchant.AMEX.SellerEmailAddress != merchant.AMEX.SellerEmailAddress)
- {
- dbmerchant.AMEX.SellerEmailAddress = merchant.AMEX.SellerEmailAddress;
- updated = true;
- }
- if (dbmerchant.AMEX.AuthorizedSignerDateOfBirth != merchant.AMEX.AuthorizedSignerDateOfBirth)
- {
- dbmerchant.AMEX.AuthorizedSignerDateOfBirth = merchant.AMEX.AuthorizedSignerDateOfBirth;
- updated = true;
- }
- if (dbmerchant.AMEX.SEDetailStatusCode != (Database.Merchant.SEDetailStatusCode) merchant.AMEX.SEDetailStatusCode)
- {
- dbmerchant.AMEX.SEDetailStatusCode = (Database.Merchant.SEDetailStatusCode) merchant.AMEX.SEDetailStatusCode;
- updated = true;
- }
- }
- if (updated)
- {
- dbmerchant.LastUpdated = DateTime.Now.ToUniversalTime();
- }
- return updated;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement