Advertisement
Kikku80

Untitled

Sep 6th, 2019
246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 5.20 KB | None | 0 0
  1.   public static bool UpdateFromAPIMerchant(this Database.Merchant dbmerchant, Merchant merchant)
  2.         {
  3.             bool updated = false;
  4.  
  5.             if (merchant.Enabled != null && dbmerchant.Enabled != merchant.Enabled)
  6.             {
  7.                 dbmerchant.Enabled = (bool) merchant.Enabled;
  8.                 updated = true;
  9.             }
  10.  
  11.             if (!string.IsNullOrEmpty(merchant.Name) && dbmerchant.Name != merchant.Name)
  12.             {
  13.                 dbmerchant.Name = merchant.Name;
  14.                 updated = true;
  15.             }
  16.  
  17.             if (!string.IsNullOrEmpty(merchant.Street) && dbmerchant.Street != merchant.Street)
  18.             {
  19.                 dbmerchant.Street = merchant.Street;
  20.                 updated = true;
  21.             }
  22.  
  23.             if (!string.IsNullOrEmpty(merchant.City) && dbmerchant.City != merchant.City)
  24.             {
  25.                 dbmerchant.City = merchant.City;
  26.                 updated = true;
  27.             }
  28.  
  29.             if (!string.IsNullOrEmpty(merchant.Country) && dbmerchant.Country != merchant.Country)
  30.             {
  31.                 dbmerchant.Country = merchant.Country;
  32.                 updated = true;
  33.             }
  34.  
  35.             if (!string.IsNullOrEmpty(merchant.PostalCode) && dbmerchant.PostalCode != merchant.PostalCode)
  36.             {
  37.                 merchant.ValidatePostalCode();
  38.                 dbmerchant.PostalCode = merchant.PostalCode;
  39.                 updated = true;
  40.             }
  41.  
  42.             if (!string.IsNullOrEmpty(merchant.TelephoneNumber) &&
  43.                 dbmerchant.TelephoneNumber != merchant.TelephoneNumber)
  44.             {
  45.                 merchant.ValidateTelephoneNumber();
  46.                 dbmerchant.TelephoneNumber = merchant.TelephoneNumber;
  47.                 updated = true;
  48.             }    
  49.  
  50.             if (!string.IsNullOrEmpty(merchant.MasterCardAssignedID) &&
  51.                 dbmerchant.MasterCardAssignedId != merchant.MasterCardAssignedID)
  52.             {
  53.                 dbmerchant.MasterCardAssignedId = merchant.MasterCardAssignedID;
  54.                 updated = true;
  55.             }
  56.  
  57.             //update merchant fields relating to American Express (AMEX)
  58.             if (merchant.AMEX != null)
  59.             {
  60.                 if (dbmerchant.AMEX == null)
  61.                 {
  62.                     dbmerchant.AMEX = new Database.Merchant.AMEXFields {Created = DateTime.Now.ToUniversalTime()};
  63.                     merchant.ValidateAMEXFields();
  64.                 }
  65.  
  66.                 if (dbmerchant.AMEX.Enabled != merchant.AMEX.Enabled)
  67.                 {
  68.                     dbmerchant.AMEX.Enabled = merchant.AMEX.Enabled;
  69.                     updated = true;
  70.                 }
  71.                
  72.                 if (dbmerchant.AMEX.TransactionSourceType != merchant.AMEX.TransactionSourceType)
  73.                 {
  74.                     dbmerchant.AMEX.TransactionSourceType = merchant.AMEX.TransactionSourceType;
  75.                     updated = true;
  76.                 }
  77.                
  78.                 if (!string.IsNullOrEmpty(merchant.AMEX.AuthorizedSignerFirstName) && dbmerchant.AMEX.AuthorizedSignerFirstName != merchant.AMEX.AuthorizedSignerFirstName)
  79.                 {
  80.                     dbmerchant.AMEX.AuthorizedSignerFirstName = merchant.AMEX.AuthorizedSignerFirstName;
  81.                     updated = true;
  82.                 }
  83.                
  84.                 if (!string.IsNullOrEmpty(merchant.AMEX.AuthorizedSignerLastName) && dbmerchant.AMEX.AuthorizedSignerLastName != merchant.AMEX.AuthorizedSignerLastName)
  85.                 {
  86.                     dbmerchant.AMEX.AuthorizedSignerLastName = merchant.AMEX.AuthorizedSignerLastName;
  87.                     updated = true;
  88.                 }
  89.                
  90.                 if (!string.IsNullOrEmpty(merchant.AMEX.AuthorizedSignerTitle) && dbmerchant.AMEX.AuthorizedSignerTitle != merchant.AMEX.AuthorizedSignerTitle)
  91.                 {
  92.                     dbmerchant.AMEX.AuthorizedSignerTitle = merchant.AMEX.AuthorizedSignerTitle;
  93.                     updated = true;
  94.                 }
  95.                
  96.                 if (!string.IsNullOrEmpty(merchant.AMEX.SellerEmailAddress) && dbmerchant.AMEX.SellerEmailAddress != merchant.AMEX.SellerEmailAddress)
  97.                 {
  98.                     dbmerchant.AMEX.SellerEmailAddress = merchant.AMEX.SellerEmailAddress;
  99.                     updated = true;
  100.                 }
  101.                
  102.                 if (dbmerchant.AMEX.AuthorizedSignerDateOfBirth != merchant.AMEX.AuthorizedSignerDateOfBirth)
  103.                 {
  104.                     dbmerchant.AMEX.AuthorizedSignerDateOfBirth = merchant.AMEX.AuthorizedSignerDateOfBirth;
  105.                     updated = true;
  106.                 }
  107.                
  108.                 if (dbmerchant.AMEX.SEDetailStatusCode != (Database.Merchant.SEDetailStatusCode) merchant.AMEX.SEDetailStatusCode)
  109.                 {
  110.                     dbmerchant.AMEX.SEDetailStatusCode = (Database.Merchant.SEDetailStatusCode) merchant.AMEX.SEDetailStatusCode;
  111.                     updated = true;
  112.                 }
  113.             }
  114.            
  115.             if (updated)
  116.             {
  117.                 dbmerchant.LastUpdated = DateTime.Now.ToUniversalTime();
  118.             }
  119.  
  120.             return updated;
  121.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement