Ejemplo n.º 1
0
 /// <summary>
 /// Convert an Ecom business account to an eagle business account
 /// </summary>
 /// <param name="ecomBusinessAccount">The Ecom business account to convert</param>
 /// <returns>The Eagle business account</returns>
 public static BusinessAccount ConvertEcomToEagle(EcomBusinessAccount ecomBusinessAccount)
 {
     return new BusinessAccount
     {
         Id = ecomBusinessAccount.Id,
         BusinessAccountTypeId = ecomBusinessAccount.BusinessAccountTypeId,
         FullName = ecomBusinessAccount.FullName,
         ShortName = ecomBusinessAccount.ShortName,
         UpdatedByUserId = ecomBusinessAccount.ModifiedByUserId
     };
 }
Ejemplo n.º 2
0
 public static EcomBusinessAccountFactory Initialise()
 {
     var defaultEcomBusinessAccount = new EcomBusinessAccount
     {
         BusinessAccountStatusTypeId = 1,
         ModifiedDate = DateTime.Now,
         CreatedByTitle = "Mr",
         CreatedByFirstname = "Test",
         CreatedByLastname = "Test",
         ModifiedByTitle = "Mr",
         ModifiedByFirstname = "Test",
         ModifiedByLastname = "Test"
     };
     return new EcomBusinessAccountFactory(defaultEcomBusinessAccount);
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Updates the data of a businessAccount and the inner channels
        /// </summary>
        /// <param name="businessAccount">Ecom business account object</param>
        /// <returns>EcomBusinessInfo object</returns>
        private EcomBusinessInfo UpdateBusinessAccountAndChannels(EcomBusinessAccount businessAccount)
        {
            UpdateBusinessAccount(businessAccount);
            UpdateContentMap(businessAccount);

            if (!String.IsNullOrEmpty(businessAccount.MerchantId))
            {
                //if they exist then update them otherwise create them
                if (IsMerchantDetailsPresent(businessAccount.MerchantId))
                {
                    UpdateMerchantDetails(businessAccount);                                    
                }
                else
                {
                    InsertMerchantDetails(businessAccount);
                }
            }            

            return UpdateChannels(businessAccount);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Updates the content map for the business
        /// </summary>
        /// <param name="businessAccount">Ecom business account object</param>
        private void UpdateContentMap(EcomBusinessAccount businessAccount)
        {
            const string SQL =
                @"UPDATE dbo.BA_CONTENTMAP
                     SET 
                        BACM_CONTENTID = @BACM_CONTENTID
                    WHERE
                        BABA_ID = @BABA_ID";

            var parameters = new List<SqlParameter>
                             {
                                 DbHelper.CreateParameter(EcomBusinessAccountMapper.BABA_ID, businessAccount.Id),
                                 DbHelper.CreateParameter(EcomBusinessAccountMapper.BACM_CONTENTID, businessAccount.ContentId)
                             };

            DbHelper.ExecuteNonQueryCommand(SQL, parameters: parameters, connStringName: ecomConnectionString);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Creates an OptIn for a business and channel
        /// </summary>
        /// <remarks>
        /// The 43 seems to cause issues with unit tests.
        /// This also needs unit tests around it.
        /// </remarks>
        /// <param name="businessAccount">Business Account</param>
        /// <param name="channelShortName">Channel Shortname</param>
        /// <param name="integrationTypeCode">Integration Type Code</param>
        private void CreateOptIn(EcomBusinessAccount businessAccount, string channelShortName, string integrationTypeCode)
        {
            var parameters = new List<SqlParameter>();

            const string SQL = @"INSERT INTO BA_PROVIDEROPTIN (
                                BAPO_ID,
                                BADC_ID,
                                BAOT_TYPE,
                                BAPO_ISBLOCKED,
                                BAPO_ISOPTINOPTIONMATCHED,
                                PCRT_ID,
                                BAPO_CACHEGROUPID,
                                BAPO_ISHIDDEN,
                                BAPO_PAYMENTOPTIONS
                                ) VALUES (
                                    (SELECT BABA_ID 
                                            FROM BA_BUSINESSACCOUNT
                                            WHERE BABA_SHORTNAME = @BABA_SHORTNAME),
                                    (SELECT BABA_ID 
                                                 FROM BA_BUSINESSACCOUNT
                                                 WHERE BABA_SHORTNAME = @CHANNEL_SHORTNAME),
                                    2,
                                    0,
                                    1,
                                    NULL,
                                    NULL,
                                    0,
                                    @BAPO_PAYMENTOPTIONS
                                ); -- Initial create should be as BOAT_TYPE 2 (ManualOptOut) ";

            var paymentOptions = GetPaymentOptionMappingIdFromList(businessAccount, channelShortName, integrationTypeCode) ?? default(int);

            parameters.Add(DbHelper.CreateParameter(EcomBusinessAccountMapper.BABA_SHORTNAME, businessAccount.ShortName));
            parameters.Add(DbHelper.CreateParameter(EcomBusinessAccountMapper.CHANNEL_SHORTNAME, channelShortName));
            parameters.Add(DbHelper.CreateParameter(EcomBusinessAccountMapper.BAPO_PAYMENTOPTIONS, paymentOptions));

            DbHelper.ExecuteNonQueryCommand(SQL, parameters: parameters, connStringName: ecomConnectionString);

            //Update the OptIn status to trigger events for LateRooms
            UpdateOptIn(businessAccount, channelShortName, integrationTypeCode, ECOMM_OPTEDIN_STATUS);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Inserts merchant details associated to a business account
        /// </summary>
        /// <param name="businessAccount">EcomBusinessAccount</param>
        private void InsertMerchantDetails(EcomBusinessAccount businessAccount)
        {
            const string SQL =
                @"INSERT INTO dbo.BA_MERCHANTINFO (
                        BABA_MERCHANTID,
                        BAMI_PASSWORD,
                        BAMI_EXPIRYDATE
                    ) VALUES (
                        @BABA_MERCHANTID,
                        @BAMI_PASSWORD,
                        @BAMI_EXPIRYDATE
                    ); ";

            var parameters = new List<SqlParameter>
                             {
                                 DbHelper.CreateParameter(EcomBusinessAccountMapper.BABA_MERCHANTID, businessAccount.MerchantId),
                                 DbHelper.CreateParameter(EcomBusinessAccountMapper.BAMI_PASSWORD, businessAccount.MerchantPassword),
                                 DbHelper.CreateParameter(EcomBusinessAccountMapper.BAMI_EXPIRYDATE, businessAccount.MerchantPasswordExpiry),
                             };

            DbHelper.ExecuteNonQueryCommand(SQL, parameters: parameters, connStringName: ecomConnectionString);
        }
Ejemplo n.º 7
0
            public void SaveBusinessAccountWhenNoExistingCreates()
            {
                using (new TestDataHelper(TestQueryEcom.POPULATE_BUSINESSES, TestQueryEcom.CLEANUP_TEST_DATA, DbHelper.ECOM_CONNECTION_STRING_NAME))
                {
                    // Arrange
                    const string NON_EXISTING_SHORT_NAME = "noexists";

                    var businessaccount = new EcomBusinessAccount
                    {
                        Id = Guid.NewGuid(),
                        ModifiedDate = DateTime.Now,
                        FullName = "FullName",
                        CreatedByTitle = "Mr",
                        CreatedByFirstname = "CreatedByFirstname",
                        CreatedByLastname = "CreatedByLastname",
                        ModifiedByTitle = "ModifiedByTitle",
                        ModifiedByFirstname = "ModifiedByFirstname",
                        ModifiedByLastname = "ModifiedByLastname",
                        BusinessAccountStatusTypeId = 1,
                        BusinessAccountTypeId = 1,
                        ReferenceCode = "123",
                        ShortName = NON_EXISTING_SHORT_NAME,
                        IsMerchant = true,
                        VatNumber = "123-859-7425",
                        MerchantId = "12345",
                        MerchantPassword = "******",
                        MerchantPasswordExpiry = DateTime.Today,
                        AllowAmex = false,
                        AllowPaypal = true,
                        AllowThreeDSecure = true,
                        ContentId = NON_EXISTING_SHORT_NAME,
                        AddressLine1 = "Test Street 1",
                        City = "London",
                        PostCode = "N1 HT9",
                        Channels = new Collection<EcomChannel>
                                       {
                                           new EcomChannel
                                               {
                                                   ChannelName = "channel1"
                                               },
                                           new EcomChannel
                                               {
                                                   ChannelName = "channel2"
                                               },
                                           new EcomChannel
                                               {
                                                   ChannelName = "channel3"
                                               }
                                       }
                    };

                    var ecomDataProvider = new EcomDataProvider();
                    // Act
                    bool isBusinessInEcomBefore = ecomDataProvider.IsBusinessPresent(businessaccount.ReferenceCode);
                    Assert.IsFalse(isBusinessInEcomBefore, "business is already in database before save");

                    ecomDataProvider.SaveBusinessAccount(businessaccount);

                    // Assert
                    bool isBusinessInEcomAfter = ecomDataProvider.IsBusinessPresent(businessaccount.ShortName);

                    Assert.IsTrue(isBusinessInEcomAfter, "business hasn't been created");
                }
            }
Ejemplo n.º 8
0
 private EcomBusinessAccountFactory(EcomBusinessAccount ecomBusinessAccount1)
 {
     ecomBusinessAccount = ecomBusinessAccount1;
 }
Ejemplo n.º 9
0
        /// <summary>
        /// Return payment option mapping id from ecom
        /// </summary>
        /// <param name="businessAccount">Business account</param>
        /// <param name="channelShortName">Channel ShortName</param>
        /// <param name="integrationTypeCode">Integration type code</param>
        /// <returns>Payment option mapping id</returns>
        private IEnumerable<EcomPaymentOption> GetValidPaymentOptionsForChannel(EcomBusinessAccount businessAccount, string channelShortName, string integrationTypeCode)
        {
            // get all payment options for the channel from ECOMM
            var paymentOptions = GetPaymentOptionsForChannel(channelShortName);

            // if we have a valid WLS/MYW integration code (new opt in / opt in change)
            if (!string.IsNullOrEmpty(integrationTypeCode) && (integrationTypeCode.Equals(MyWebIntegrationTypeCode, StringComparison.InvariantCultureIgnoreCase) || integrationTypeCode.Equals(WhitelabelIntegrationTypeCode, StringComparison.InvariantCultureIgnoreCase)))
            {
                // clear out list and update with supported set prepay method in Eagle
                paymentOptions.Clear();
                var channel = businessAccount.Channels.FirstOrDefault(c => c.ChannelName == channelShortName);                

                if (channel != null && channel.PrePayRuleValue.HasValue && channel.PrePayRuleType != PrePayRuleTypeEnum.Unknown)
                {
                    switch (channel.PrePayRuleType)
                    {
                        case PrePayRuleTypeEnum.Amount:
                            {
                                paymentOptions.Add(new EcomPaymentOption { Id = CUSTOM_DEPOSIT });
                                break;
                            }
                        case PrePayRuleTypeEnum.Percentage:
                            {
                                paymentOptions.Add(new EcomPaymentOption { Id = channel.PrePayRuleValue.Value == FULL_PAYMENT_PERCENTAGE ? FULL_PAYMENT : CUSTOM_DEPOSIT });
                                break;
                            }
                        case PrePayRuleTypeEnum.Nights:
                            {
                                paymentOptions.Add(new EcomPaymentOption { Id = channel.PrePayRuleValue.Value == FIRST_NIGHT ? BOOKING_DEPOSIT : CUSTOM_DEPOSIT });
                                break;
                            }
                    }
                }
                else
                {
                    paymentOptions.Add(new EcomPaymentOption { Id = FULL_PAYMENT });
                }
            }

            return paymentOptions;
        }
Ejemplo n.º 10
0
 /// <summary>
 /// Creates the sql parameters for Insert and Update business accounts
 /// </summary>
 /// <param name="businessAccount"></param>
 /// <returns>List of parameters</returns>
 private static List<SqlParameter> CreateParameters(EcomBusinessAccount businessAccount)
 {
     var parameters = new List<SqlParameter>
                      {
                          DbHelper.CreateParameter(EcomBusinessAccountMapper.BABA_ID, businessAccount.Id),
                          DbHelper.CreateParameter(EcomBusinessAccountMapper.BABA_CREATEDBY_TITLE, businessAccount.CreatedByTitle),
                          DbHelper.CreateParameter(EcomBusinessAccountMapper.BABA_CREATEDBY_FIRSTNAME, businessAccount.CreatedByFirstname),
                          DbHelper.CreateParameter(EcomBusinessAccountMapper.BABA_CREATEDBY_LASTNAME, businessAccount.CreatedByLastname),
                          DbHelper.CreateParameter(EcomBusinessAccountMapper.BABA_MODIFIEDBY_TITLE, businessAccount.ModifiedByTitle),
                          DbHelper.CreateParameter(EcomBusinessAccountMapper.BABA_MODIFIEDBY_FIRSTNAME, businessAccount.ModifiedByFirstname),
                          DbHelper.CreateParameter(EcomBusinessAccountMapper.BABA_MODIFIEDBY_LASTNAME, businessAccount.ModifiedByLastname),
                          DbHelper.CreateParameter(EcomBusinessAccountMapper.BABA_MODIFICATIONDATE, businessAccount.ModifiedDate),
                          DbHelper.CreateParameter(EcomBusinessAccountMapper.BAAS_TYPE, businessAccount.BusinessAccountStatusTypeId),
                          DbHelper.CreateParameter(EcomBusinessAccountMapper.BAAT_TYPE, businessAccount.BusinessAccountTypeId),
                          DbHelper.CreateParameter(EcomBusinessAccountMapper.BABA_FULLNAME, businessAccount.FullName),
                          DbHelper.CreateParameter(EcomBusinessAccountMapper.BABA_SHORTNAME, businessAccount.ShortName),
                          DbHelper.CreateParameter(EcomBusinessAccountMapper.BABA_REFERENCECODE, businessAccount.ReferenceCode),
                          DbHelper.CreateParameter(EcomBusinessAccountMapper.BABA_ISMERCHANT, businessAccount.IsMerchant),
                          DbHelper.CreateParameter(EcomBusinessAccountMapper.BABA_VATNUMBER, businessAccount.VatNumber),
                          DbHelper.CreateParameter(EcomBusinessAccountMapper.BABA_MERCHANTID, businessAccount.MerchantId),
                          DbHelper.CreateParameter(EcomBusinessAccountMapper.BABA_ALLOWAMEX, businessAccount.AllowAmex),
                          DbHelper.CreateParameter(EcomBusinessAccountMapper.BABA_ALLOWPAYPAL, businessAccount.AllowPaypal),
                          DbHelper.CreateParameter(EcomBusinessAccountMapper.BABA_ALLOWTHREEDSECURE, businessAccount.AllowThreeDSecure),
                          DbHelper.CreateParameter(EcomBusinessAccountMapper.BABA_FEATURES, businessAccount.Features),
                          DbHelper.CreateParameter(EcomBusinessAccountMapper.BABA_TAXREGISTERED, businessAccount.TaxRegistered),
                          DbHelper.CreateParameter(EcomBusinessAccountMapper.COCD_BUSINESS_ID, businessAccount.BusinessContactId),
                          DbHelper.CreateParameter(EcomBusinessAccountMapper.COCD_BANK_ID, businessAccount.BankContactId),
                          DbHelper.CreateParameter(EcomBusinessAccountMapper.COCD_SETTLEMENT_ID, businessAccount.SettlementContactId),
                          DbHelper.CreateParameter(EcomBusinessAccountMapper.COCD_MERCHANT_ID, businessAccount.MerchantContactId)
                      };
     return parameters;
 }
Ejemplo n.º 11
0
        /// <summary>
        /// Inserts a business account
        /// </summary>
        /// <param name="businessAccount">EcomBusinessAccount</param>
        /// <returns>EcomBusinessInfo object</returns>
        internal void InsertBusinessAccount(EcomBusinessAccount businessAccount)
        {
            const string SQL =
                @"INSERT INTO dbo.BA_BUSINESSACCOUNT (
                        BABA_ID,
                        BABA_CREATEDBY_TITLE,
                        BABA_CREATEDBY_FIRSTNAME,
                        BABA_CREATEDBY_LASTNAME,
                        BABA_MODIFIEDBY_TITLE,
                        BABA_MODIFIEDBY_FIRSTNAME,
                        BABA_MODIFIEDBY_LASTNAME,
                        BABA_MODIFICATIONDATE,
                        BAAS_TYPE,
                        BAAT_TYPE,
                        BABA_FULLNAME,
                        BABA_SHORTNAME,
                        BABA_REFERENCECODE,
                        BABA_ISMERCHANT,
                        BABA_ALLOWPAYPAL,
                        BABA_ALLOWTHREEDSECURE,
                        BABA_ALLOWAMEX,
                        BABA_MERCHANTID,
                        BABA_TAXREGISTERED,
                        BABA_FEATURES,
                        COCD_BUSINESS_ID,
                        COCD_BANK_ID,
                        COCD_SETTLEMENT_ID,
                        COCD_MERCHANT_ID,
                        BABA_HOLDER_FIRSTNAME, 
                        BABA_HOLDER_LASTNAME,
                        BABA_HOLDER_TITLE
                    ) VALUES (
                        @BABA_ID,
                        @BABA_CREATEDBY_TITLE,
                        @BABA_CREATEDBY_FIRSTNAME,
                        @BABA_CREATEDBY_LASTNAME,
                        @BABA_MODIFIEDBY_TITLE,
                        @BABA_MODIFIEDBY_FIRSTNAME,
                        @BABA_MODIFIEDBY_LASTNAME,
                        @BABA_MODIFICATIONDATE,
                        @BAAS_TYPE,
                        @BAAT_TYPE,
                        @BABA_FULLNAME,
                        @BABA_SHORTNAME,
                        @BABA_REFERENCECODE,
                        @BABA_ISMERCHANT,
                        @BABA_ALLOWPAYPAL,
                        @BABA_ALLOWTHREEDSECURE,
                        @BABA_ALLOWAMEX,
                        @BABA_MERCHANTID,
                        @BABA_TAXREGISTERED,
                        @BABA_FEATURES,
                        @COCD_BUSINESS_ID,
                        @COCD_BANK_ID,
                        @COCD_SETTLEMENT_ID,
                        @COCD_MERCHANT_ID,
                        '',
                        '',
                        ''
                ); ";

            List<SqlParameter> parameters = CreateParameters(businessAccount);

            DbHelper.ExecuteNonQueryCommand(SQL, parameters: parameters, connStringName: ecomConnectionString);
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Inserts EPP details associated for a business account
        /// </summary>
        /// <param name="businessAccount">EcomBusinessAccount</param>
        internal void InsertExernalProductProvider(EcomBusinessAccount businessAccount)
        {
            // BAEP_DMSID needs to be the business shortname, which is then passed by ABS to the Eagle adapter service

            const string SQL =
                @"INSERT INTO dbo.BA_EXTERNALPRODUCTPROVIDER (
                        BABA_ID,
                        BABA_ESPID,
                        BAEP_DELEGATESETTLEMENT,
                        BAEP_DELEGATENOTIFICATION,
                        BAEP_DMSID
                    ) VALUES (
                        @BABA_ID,
                        @BABA_ESPID,
                        @BAEP_DELEGATESETTLEMENT,
                        @BAEP_DELEGATENOTIFICATION,
                        @BABA_SHORTNAME
                    ); ";


            List<SqlParameter> parameters = CreateParameters(businessAccount);
            parameters.Add(DbHelper.CreateParameter(EcomBusinessAccountMapper.BABA_ESPID, EagleESPId));
            parameters.Add(DbHelper.CreateParameter(EcomBusinessAccountMapper.BAEP_DELEGATESETTLEMENT, 1));
            parameters.Add(DbHelper.CreateParameter(EcomBusinessAccountMapper.BAEP_DELEGATENOTIFICATION, 1));
            parameters.Add(DbHelper.CreateParameter(EcomBusinessAccountMapper.BAMT_TYPE, 1));

            DbHelper.ExecuteNonQueryCommand(SQL, parameters: parameters, connStringName: ecomConnectionString);
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Saves a business account into Ecom.
        /// Inserts it if it doesn't exist yet. Updates the existing one if already exists
        /// </summary>
        /// <param name="businessAccount">business account to save</param>
        /// <returns>EcomBusinessInfo object</returns>
        public EcomBusinessInfo SaveBusinessAccount(EcomBusinessAccount businessAccount)
        {
            EcomBusinessInfo businessInfo = null; 

              //If it not commited it would be rollback
            using (var tx = new BusinessTransaction())
            {
                if (IsBusinessPresent(businessAccount.ShortName))
                {
                    if (IsEagleBusiness(businessAccount.ShortName))
                    {
                        businessInfo = UpdateBusinessAccountAndChannels(businessAccount);
                    }
                }
                else
                {
                    businessInfo = InsertBusinessAccountAndChannels(businessAccount);
                }

                tx.Commit();
            }

            return businessInfo;
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Insert Contacts for a business account
        /// </summary>
        /// <param name="businessAccount">businessAccount</param>
        private void InsertContacts(EcomBusinessAccount businessAccount)
        {
            var businessContactPhoneId = Guid.NewGuid();
            var merchantContactPhoneId = Guid.NewGuid();
            var bankContactPhoneId = Guid.NewGuid();
            var settlmentContactPhoneId = Guid.NewGuid();

            InsertContactPhones(businessContactPhoneId, merchantContactPhoneId, bankContactPhoneId, settlmentContactPhoneId);

            var businessContactId = Guid.NewGuid();
            var merchantContactId = Guid.NewGuid();
            var bankContactId = Guid.NewGuid();
            var settlmentContactId = Guid.NewGuid();

            businessAccount.BusinessContactId = businessContactId;
            businessAccount.MerchantContactId = merchantContactId;
            businessAccount.BankContactId = bankContactId;
            businessAccount.SettlementContactId = settlmentContactId;

            const string SQL = @"INSERT INTO CO_CONTACTDETAILS (COCD_ID, COCD_ADDRESS1, COCD_CITY, COCD_POSTCODE, COCT_ID, COPH_ID) 
                                 VALUES (@COCD_BUSINESS_ID, @COCD_ADDRESS1, @COCD_CITY, @COCD_POSTCODE, @COCT_ID, @COPH_BUSINESS_ID),
                                        (@COCD_BANK_ID, @COCD_ADDRESS1, @COCD_CITY, @COCD_POSTCODE, @COCT_ID, @COPH_BANK_ID),
                                        (@COCD_MERCHANT_ID, @COCD_ADDRESS1, @COCD_CITY, @COCD_POSTCODE, @COCT_ID, @COPH_MERCHANT_ID),
                                        (@COCD_SETTLEMENT_ID, @COCD_ADDRESS1, @COCD_CITY, @COCD_POSTCODE, @COCT_ID, @COPH_SETTLEMENT_ID)";

            var parameters = new List<SqlParameter>
            {
                DbHelper.CreateParameter(EcomBusinessAccountMapper.COCD_BUSINESS_ID, businessAccount.BusinessContactId),
                DbHelper.CreateParameter(EcomBusinessAccountMapper.COCD_BANK_ID, businessAccount.BankContactId),
                DbHelper.CreateParameter(EcomBusinessAccountMapper.COCD_MERCHANT_ID, businessAccount.MerchantContactId),
                DbHelper.CreateParameter(EcomBusinessAccountMapper.COCD_SETTLEMENT_ID, businessAccount.SettlementContactId),
                DbHelper.CreateParameter(EcomBusinessAccountMapper.COCD_ADDRESS1, businessAccount.AddressLine1),
                DbHelper.CreateParameter(EcomBusinessAccountMapper.COCD_CITY, businessAccount.City),
                DbHelper.CreateParameter(EcomBusinessAccountMapper.COCD_POSTCODE, businessAccount.PostCode),
                DbHelper.CreateParameter(EcomBusinessAccountMapper.COCT_ID, DefaultCountryId),
                DbHelper.CreateParameter(EcomBusinessAccountMapper.COPH_BUSINESS_ID, businessContactPhoneId),
                DbHelper.CreateParameter(EcomBusinessAccountMapper.COPH_BANK_ID, bankContactPhoneId),
                DbHelper.CreateParameter(EcomBusinessAccountMapper.COPH_MERCHANT_ID, merchantContactPhoneId),
                DbHelper.CreateParameter(EcomBusinessAccountMapper.COPH_SETTLEMENT_ID, settlmentContactPhoneId)
            };

            DbHelper.ExecuteNonQueryCommand(SQL, parameters: parameters, connStringName: ecomConnectionString);
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Updates an OptIn for a business and channel
        /// </summary>
        /// <param name="businessAccount">Business Account</param>
        /// <param name="channelShortName">Channel Shortname</param>
        /// <param name="integrationTypeCode">Integration Type Code</param>
        /// <param name="optInStatus">Opt In Status</param>
        private void UpdateOptIn(EcomBusinessAccount businessAccount, string channelShortName, string integrationTypeCode, int optInStatus)
        {
            var parameters = new List<SqlParameter>();

            const string SQL = @"UPDATE BA_PROVIDEROPTIN SET BAOT_TYPE = @BAOT_TYPE, BAPO_PAYMENTOPTIONS = @BAPO_PAYMENTOPTIONS
                                 WHERE BAPO_ID = (SELECT BABA_ID FROM BA_BUSINESSACCOUNT
                                                  WHERE BABA_SHORTNAME = @BABA_SHORTNAME)
                                 AND BADC_ID =  (SELECT BABA_ID FROM BA_BUSINESSACCOUNT
                                                  WHERE BABA_SHORTNAME = @CHANNEL_SHORTNAME)
                                 AND (BAPO_PAYMENTOPTIONS != @BAPO_PAYMENTOPTIONS OR BAOT_TYPE != @BAOT_TYPE); ";

            var paymentOptions = GetPaymentOptionMappingIdFromList(businessAccount, channelShortName, integrationTypeCode) ?? default(int);

            parameters.Add(DbHelper.CreateParameter(EcomChannelMapper.BAOT_TYPE, optInStatus));
            parameters.Add(DbHelper.CreateParameter(EcomBusinessAccountMapper.BABA_SHORTNAME, businessAccount.ShortName));
            parameters.Add(DbHelper.CreateParameter(EcomBusinessAccountMapper.CHANNEL_SHORTNAME, channelShortName));
            parameters.Add(DbHelper.CreateParameter(EcomPaymentOptionMapper.BAPO_PAYMENTOPTIONS, paymentOptions));

            DbHelper.ExecuteNonQueryCommand(SQL, parameters: parameters, connStringName: ecomConnectionString);            
        }
Ejemplo n.º 16
0
        /// <summary>
        /// Updates the merchant data for a business account
        /// </summary>
        /// <param name="businessAccount">Ecom business account object</param>
        private void UpdateMerchantDetails(EcomBusinessAccount businessAccount)
        {
            const string SQL =
                @"UPDATE dbo.BA_MERCHANTINFO
                     SET 
                        BAMI_PASSWORD = @BAMI_PASSWORD,
                        BAMI_EXPIRYDATE = @BAMI_EXPIRYDATE
                    WHERE
                        BABA_MERCHANTID = @BABA_MERCHANTID";

            var parameters = new List<SqlParameter>
                             {
                                 DbHelper.CreateParameter(EcomBusinessAccountMapper.BABA_MERCHANTID, businessAccount.MerchantId),
                                 DbHelper.CreateParameter(EcomBusinessAccountMapper.BAMI_PASSWORD, businessAccount.MerchantPassword),
                                 DbHelper.CreateParameter(EcomBusinessAccountMapper.BAMI_EXPIRYDATE, businessAccount.MerchantPasswordExpiry)
                             };

            DbHelper.ExecuteNonQueryCommand(SQL, parameters: parameters, connStringName: ecomConnectionString);
        }
Ejemplo n.º 17
0
        /// <summary>
        /// Return payment option mapping id from ecom
        /// </summary>
        /// <param name="businessAccount">Business account</param>
        /// <param name="channelShortName">Channel ShortName</param>
        /// <param name="integrationTypeCode">Integration type code</param>
        /// <returns>Payment option mapping id</returns>
        private int? GetPaymentOptionMappingIdFromList(EcomBusinessAccount businessAccount, string channelShortName, string integrationTypeCode)
        {
            var validPaymentOptions = GetValidPaymentOptionsForChannel(businessAccount, channelShortName, integrationTypeCode);
            var arrayOfOptions = validPaymentOptions.Select(p => p.Id).ToArray();
            var delimitedList = string.Join(",", arrayOfOptions);

            const string SQL_QUERY = @"SELECT BAPO_PAYMENTOPTIONS FROM BA_PROVIDEROPTIN_PAYMENTOPTIONS_MAPPING
                                       WHERE BAPO_PAYMENTOPTION_ID_LIST = @BAPO_PAYMENTOPTION_ID_LIST ";

            var parameters = new List<SqlParameter>
                                 {
                                     DbHelper.CreateParameter(EcomPaymentOptionMapper.BAPO_PAYMENTOPTION_ID_LIST, delimitedList)
                                 };

            return DbHelper.ExecuteScalar<int?>(SQL_QUERY, connStringName: ecomConnectionString, parameters: parameters);
        }
Ejemplo n.º 18
0
        /// <summary>
        /// Updates the data of a businessAccount
        /// </summary>
        /// <param name="businessAccount">Ecom business account object</param>
        internal void UpdateBusinessAccount(EcomBusinessAccount businessAccount)
        {
            const string SQL =
                @"UPDATE dbo.BA_BUSINESSACCOUNT
                     SET 
                        BABA_CREATEDBY_TITLE = @BABA_CREATEDBY_TITLE,
                        BABA_CREATEDBY_FIRSTNAME = @BABA_CREATEDBY_FIRSTNAME,
                        BABA_CREATEDBY_LASTNAME = @BABA_CREATEDBY_LASTNAME,
                        BABA_MODIFIEDBY_TITLE = @BABA_MODIFIEDBY_TITLE,
                        BABA_MODIFIEDBY_FIRSTNAME = @BABA_MODIFIEDBY_FIRSTNAME,
                        BABA_MODIFIEDBY_LASTNAME = @BABA_MODIFIEDBY_LASTNAME,
                        BABA_MODIFICATIONDATE = @BABA_MODIFICATIONDATE,
                        BAAS_TYPE = @BAAS_TYPE,
                        BAAT_TYPE = @BAAT_TYPE,
                        BABA_FULLNAME = @BABA_FULLNAME,
                        BABA_REFERENCECODE = @BABA_REFERENCECODE,
                        BABA_ISMERCHANT = @BABA_ISMERCHANT,
                        BABA_ALLOWPAYPAL = @BABA_ALLOWPAYPAL,
                        BABA_ALLOWTHREEDSECURE = @BABA_ALLOWTHREEDSECURE,
                        BABA_ALLOWAMEX  = @BABA_ALLOWAMEX,
                        BABA_MERCHANTID = @BABA_MERCHANTID,
                        BABA_TAXREGISTERED = @BABA_TAXREGISTERED,
                        BABA_FEATURES = @BABA_FEATURES
                    WHERE
                        BABA_SHORTNAME = @BABA_SHORTNAME";

            List<SqlParameter> parameters = CreateParameters(businessAccount);

            DbHelper.ExecuteNonQueryCommand(SQL, parameters: parameters, connStringName: ecomConnectionString);
        }
Ejemplo n.º 19
0
        /// <summary>
        /// Inserts a business account and the related data into ExternalProductProvider, ContentMap and ProviderOptIn tables
        /// </summary>
        /// <param name="businessAccount">EcomBusinessAccount</param>
        /// <returns>EcomBusinessInfo object</returns>
        private EcomBusinessInfo InsertBusinessAccountAndChannels(EcomBusinessAccount businessAccount)
        {
            InsertContacts(businessAccount);
            InsertBusinessAccount(businessAccount);
            InsertExernalProductProvider(businessAccount);
            InsertContentMap(businessAccount);
            InsertOptinOptionsIndustryClassification(businessAccount);

            if (!String.IsNullOrEmpty(businessAccount.MerchantId))
            {
                //if they exist then update them otherwise create them
                if (IsMerchantDetailsPresent(businessAccount.MerchantId))
                {
                    UpdateMerchantDetails(businessAccount);
                }
                else
                {
                    InsertMerchantDetails(businessAccount);
                }
            }  

            var info = CreateChannels(businessAccount);

            return info;
        }
Ejemplo n.º 20
0
        /// <summary>
        /// Drops and recreates the channel - business account relationships 
        /// </summary>
        /// <param name="businessAccount">EcomBusinessAccount</param>
        /// <returns>EcomBusinessInfo object</returns>
        private EcomBusinessInfo UpdateChannels(EcomBusinessAccount businessAccount)
        {
            var ecomBusinessInfo = new EcomBusinessInfo();

            if (businessAccount.Channels == null || !businessAccount.Channels.Any())
            {
                return ecomBusinessInfo;
            }

            //Get list of Ecomm opt ins for the Business
            var ecommOptIns = GetEcommOptInsForBusiness(businessAccount.ShortName);

            //Handle all the Opt Ins First
            foreach (var channel in businessAccount.Channels)
            {
                var channelId = GetChannelId(channel.ChannelName);

                if (channelId != null)
                {
                    ecomBusinessInfo.AddedChannels.Add(channel.ChannelName);

                    //If opt in doesnt exist in ECOMM then create it
                    if (!ecommOptIns.Any(c => c.ChannelName.Equals(channel.ChannelName, StringComparison.InvariantCultureIgnoreCase)))
                    {
                        CreateOptIn(businessAccount, channel.ChannelName, channel.IntegrationTypeCode);     
                    }
                    else if (ecommOptIns.Any(c => c.ChannelName.Equals(channel.ChannelName, StringComparison.InvariantCultureIgnoreCase)))
                    {
                        UpdateOptIn(businessAccount, channel.ChannelName, channel.IntegrationTypeCode, ECOMM_OPTEDIN_STATUS);
                    }
                }
                else
                {
                    ecomBusinessInfo.MissingChannels.Add(channel.ChannelName);
                }                
            }

            foreach (var channel in ecommOptIns)
            {
                if (!businessAccount.DoesChannelExist(channel.ChannelName))
                {
                    ecomBusinessInfo.AddedChannels.Add(channel.ChannelName);

                    UpdateOptIn(businessAccount, channel.ChannelName, channel.IntegrationTypeCode, ECOMM_OPTEDOUT_STATUS);
                }
            }

            return ecomBusinessInfo;
        }
Ejemplo n.º 21
0
        /// <summary>
        /// Converts Eagle Businesses to Ecom BusinessAccounts
        /// </summary>
        /// <param name="business">Business in eagle</param>
        /// <param name="channelSyncCode">Channel sync code</param>
        /// <param name="missedChannels">Missed channels</param>
        /// <returns>Business in Ecom</returns>
        public static EcomBusinessAccount EagleBusinessToEcom(Business business, string channelSyncCode, out List<string> missedChannels)
        {
            missedChannels = new List<string>();

            if (business == null)
            {
                return null;
            }

            var eagleBusinessToEcom = new EcomBusinessAccount
            {
                Id = business.Id.ToGuid(),
                CreatedByTitle = string.Empty,
                CreatedByFirstname = business.CreatedByUser.FirstName ?? EAGLE_INTERNAL_FIRSTNAME,
                CreatedByLastname = business.CreatedByUser.LastName ?? EAGLE_INTERNAL_LASTNAME,
                ModifiedByTitle = string.Empty,
                ModifiedByFirstname = business.UpdatedByUser.FirstName ?? EAGLE_INTERNAL_FIRSTNAME,
                ModifiedByLastname = business.UpdatedByUser.LastName ?? EAGLE_INTERNAL_LASTNAME,
                ModifiedDate =  business.UpdatedDateTime,
                BusinessAccountTypeId = MapBusinessType(business.BusinessType),
                FullName = business.Name, 
                ShortName = business.ShortName, 
                ReferenceCode = business.ReferenceCode,
                Channels = MapChannels(business.Distributors, channelSyncCode, out missedChannels),
                IsMerchant = (business.MerchantStatusEnum == MerchantStatusEnum.OwnMerchant),
                VatNumber = business.TaxRegistrationNumber,
                TaxRegistered = business.IsTaxRegistered,
                BusinessRegistrationNumber = business.BusinessRegistrationNumber,
                AddressLine1 = business.AddressLine1,
                City = business.City,
                PostCode = business.PostCode,
                ContentId = business.Provider.ContentId
            };

            // if we have a list of booking scenarios then set valid fields
            if (business.OnlineBookingScenarios != null)
            {
                eagleBusinessToEcom.MyWebFirstNightDeposit =
                    business.OnlineBookingScenarios.Any(
                        o =>
                        o.IntegrationTypeCode == IntegrationTypeEnum.Myweb.GetCode() &&
                        o.BookingScenarioCode == BookingScenarioTypeEnum.DepositFirstNight.GetCode());
                eagleBusinessToEcom.MyWebPrepaid =
                    business.OnlineBookingScenarios.Any(
                        o =>
                        o.IntegrationTypeCode == IntegrationTypeEnum.Myweb.GetCode() &&
                        o.BookingScenarioCode == BookingScenarioTypeEnum.Prepaid.GetCode());
                eagleBusinessToEcom.WlsFirstNightDeposit =
                    business.OnlineBookingScenarios.Any(
                        o =>
                        o.IntegrationTypeCode == IntegrationTypeEnum.WhiteLabel.GetCode() &&
                        o.BookingScenarioCode == BookingScenarioTypeEnum.DepositFirstNight.GetCode());
                eagleBusinessToEcom.WlsPrepaid =
                    business.OnlineBookingScenarios.Any(
                        o =>
                        o.IntegrationTypeCode == IntegrationTypeEnum.WhiteLabel.GetCode() &&
                        o.BookingScenarioCode == BookingScenarioTypeEnum.Prepaid.GetCode());
            }
                
            //only map the merchant details if they exist in Eagle
            if (business.MerchantDetails != null && eagleBusinessToEcom.IsMerchant)
            {
                eagleBusinessToEcom.MerchantId = business.MerchantDetails.MerchantId;
                eagleBusinessToEcom.MerchantPasswordExpiry = business.MerchantDetails.PasswordExpiry.GetValueOrDefault();
                eagleBusinessToEcom.MerchantPassword = business.MerchantDetails.Password;
                eagleBusinessToEcom.AllowThreeDSecure = business.MerchantDetails.Is3DSecureAllowed.GetValueOrDefault();
                eagleBusinessToEcom.AllowAmex = business.MerchantDetails.IsAmexAllowed.GetValueOrDefault();
                eagleBusinessToEcom.AllowPaypal = business.MerchantDetails.IsPaypalAllowed.GetValueOrDefault();
            }
            else
            {
                eagleBusinessToEcom.MerchantId = string.Empty;  //clear out merchant id when business is not a merchant or no merchant details exist
            }
            
            return eagleBusinessToEcom;
        }
Ejemplo n.º 22
0
            public void SaveBusinessAccountWhenExisitingUpdates()
            {
                using (new TestDataHelper(TestQueryEcom.POPULATE_BUSINESSES, TestQueryEcom.CLEANUP_TEST_DATA, DbHelper.ECOM_CONNECTION_STRING_NAME))
                {
                    // Arrange
                    const string SHORT_NAME = "Bus2";

                    DateTime startUpdate = DateTime.UtcNow;

                    var businessaccount = new EcomBusinessAccount
                    {
                        Id = new Guid("1D99ACCA-8F44-44C9-A277-00BF03D7BA69"),
                        ModifiedDate = DateTime.Now,
                        FullName = "FullName",
                        CreatedByTitle = "Mr",
                        CreatedByFirstname = "CreatedByFirstname",
                        CreatedByLastname = "CreatedByLastname",
                        ModifiedByTitle = "ModifiedByTitle",
                        ModifiedByFirstname = "ModifiedByFirstname",
                        ModifiedByLastname = "ModifiedByLastname",
                        BusinessAccountStatusTypeId = 1,
                        BusinessAccountTypeId = 1,
                        ReferenceCode = "1000133",
                        ShortName = SHORT_NAME,
                        IsMerchant = true,
                        VatNumber = "123-859-7425",
                        MerchantId = "MERCH1627",
                        MerchantPassword = "******",
                        MerchantPasswordExpiry = DateTime.Today,
                        AllowAmex = false,
                        AllowPaypal = true,
                        AllowThreeDSecure = true,
                        ContentId = SHORT_NAME,
                        Channels = new Collection<EcomChannel>
                                       {
                                           new EcomChannel
                                               {
                                                   ChannelName = "toprooms"
                                               }
                                       }
                    };

                    // Act
                    bool isBusinessInEcomBefore = new EcomDataProvider().IsBusinessPresent(businessaccount.ShortName);
                    Assert.IsTrue(isBusinessInEcomBefore, "business should be already in database before save");

                    new EcomDataProvider().SaveBusinessAccount(businessaccount);

                    // Assert
                    DateTime updatedDateTime = new EcomDataProvider().GetMostRecentBusinessUpdateTime();

                    Assert.IsTrue(updatedDateTime.AddMinutes(1) >= startUpdate.AddMinutes(-1));
                }
            }
Ejemplo n.º 23
0
        /// <summary>
        /// Inserts a content map for a business account
        /// </summary>
        /// <param name="businessAccount">EcomBusinessAccount</param>
        private void InsertContentMap(EcomBusinessAccount businessAccount)
        {
            const string SQL =
                @"INSERT INTO dbo.BA_CONTENTMAP (
                        BACM_ID,
                        BACM_CONTENTID, 
                        BABA_ID,
                        BAMT_TYPE
                    ) VALUES (
                        NEWID(),
                        @BACM_CONTENTID,
                        @BABA_ID,
                        @BAMT_TYPE
                    ); ";


            List<SqlParameter> parameters = CreateParameters(businessAccount);
            parameters.Add(DbHelper.CreateParameter(EcomBusinessAccountMapper.BACM_CONTENTID, businessAccount.ContentId));
            parameters.Add(DbHelper.CreateParameter(EcomBusinessAccountMapper.BAMT_TYPE, 1));            

            DbHelper.ExecuteNonQueryCommand(SQL, parameters: parameters, connStringName: ecomConnectionString);
        }
Ejemplo n.º 24
0
        /// <summary>
        /// Inserts industry classifications for opt ins
        /// </summary>
        /// <param name="businessAccount">EcomBusinessAccount</param>
        private void InsertOptinOptionsIndustryClassification(EcomBusinessAccount businessAccount)
        {
            const string SQL =
              @"INSERT INTO dbo.BA_OPTINOPTIONSIC (
                        COIC_ID,
                        BABA_ID
                    ) VALUES (
                        @COIC_ID,
                        @BABA_ID
                    ); ";

            List<SqlParameter> parameters = CreateParameters(businessAccount);
            parameters.Add(DbHelper.CreateParameter(EcomBusinessAccountMapper.COIC_ID, DefaultIndustryClassification));

            DbHelper.ExecuteNonQueryCommand(SQL, parameters: parameters, connStringName: ecomConnectionString);
        }
Ejemplo n.º 25
0
        /// <summary>
        /// Relates channels with a business account
        /// </summary>
        /// <param name="businessAccount">EcomBusinessAccount</param>
        /// <returns>EcomBusinessInfo object</returns>
        private EcomBusinessInfo CreateChannels(EcomBusinessAccount businessAccount)
        {
            var ecomBusinessInfo = new EcomBusinessInfo();

            if (businessAccount.Channels == null || !businessAccount.Channels.Any())
            {
                return ecomBusinessInfo;
            }

            foreach (var channel in businessAccount.Channels)
            {
                var channelId = GetChannelId(channel.ChannelName);

                if (channelId != null)
                {
                    ecomBusinessInfo.AddedChannels.Add(channel.ChannelName);

                    CreateOptIn(businessAccount, channel.ChannelName, channel.IntegrationTypeCode);
                }
                else
                {
                    ecomBusinessInfo.MissingChannels.Add(channel.ChannelName);
                }
            }

            return ecomBusinessInfo;
        }