/// <summary>
        /// Create a new businessChannel record
        /// </summary>
        /// <param name="businessChannel">The businessChannel to create</param>
        public void Create(BusinessChannelOverride businessChannel)
        {
            const string SQL_STATEMENT = @"
                INSERT INTO Distribution.BusinessChannelOverride
                           (BusinessId,
                            ChannelId,
                            DistributorCommission,
                            EviivoCommission,
                            UpdatedDatetime,
                            UpdatedByUserId,
                            DctCommissionDisplay,
                            IsVisible,
                            CurrencyCode)
                      VALUES
                           (@BusinessId,
                            @ChannelId,
                            @DistributorCommission,
                            @EviivoCommission,
                            @UpdatedDatetime,
                            @UpdatedByUserId,
                            @DctCommissionDisplay,
                            @IsVisible,
                            @CurrencyCode)
                SELECT @Id = SCOPE_IDENTITY()";

            var parameters = new List<SqlParameter>
            {
                DbHelper.CreateParameter(BusinessChannelOverrideMapper.Parameters.BusinessId, businessChannel.BusinessId),
                DbHelper.CreateParameter(BusinessChannelOverrideMapper.Parameters.ChannelId, businessChannel.ChannelId),
                DbHelper.CreateParameter(BusinessChannelOverrideMapper.Parameters.DistributorCommission, businessChannel.DistributorCommission),
                DbHelper.CreateParameter(BusinessChannelOverrideMapper.Parameters.EviivoCommission, businessChannel.EviivoCommission),
                DbHelper.CreateParameter(BusinessChannelOverrideMapper.Parameters.UpdatedDatetime, DateTime.UtcNow),
                DbHelper.CreateParameter(BusinessChannelOverrideMapper.Parameters.DctCommissionDisplay, businessChannel.DctCommissionDisplay),
                DbHelper.CreateParameter(BusinessChannelOverrideMapper.Parameters.IsVisible, businessChannel.IsVisible),
                 DbHelper.CreateParameter(BusinessChannelOverrideMapper.Parameters.CurrencyCode, businessChannel.CurrencyCode)
            };

            // Add auditing parameters
            AuditFieldsHelper.PopulateAuditFields(parameters);

            SqlParameter outputKey;
            parameters.Add(outputKey = DbHelper.CreateParameterOut<int>(BusinessChannelOverrideMapper.Parameters.Id, SqlDbType.Int));

            DbHelper.ExecuteNonQueryCommand(SQL_STATEMENT, parameters: parameters);

            // Make sure the record was created
            if (outputKey.Value == DBNull.Value)
            {
                throw new PrimaryKeyNotSetException(ErrorFactory.CreateAndLogError(Errors.SRVEX30022, "BusinessChannelOverride.Create",
                    additionalDescriptionParameters: (new object[] { businessChannel.BusinessId, businessChannel.ChannelId })));
            }

            businessChannel.Id = DbHelper.ParameterValue<int>(outputKey);
        }
            public void CreateWithCorrectArgumentIsSuccessful()
            {
                // Arrange
                var businessChannelOverride = new BusinessChannelOverride()
                {
                    DisplayCommission = "Display Commission test",
                    IsVisible = false,
                    BusinessId = 1,
                    ChannelId = channelDao.GetChannelIdByShortName("toprooms").Value,
                    EviivoCommission = 20,
                    DistributorCommission = 30
                };

                // Act
                businessChannelOverrideDao.Create(businessChannelOverride);

                // Assert
                Assert.IsNotNull(businessChannelOverride.Id, "Expected Id for new entry.");

            }
Example #3
0
 /// <summary>
 /// Update the commission display
 /// </summary>
 /// <param name="businessChannelOverride">Override to be modified</param>
 private void UpsertCommissionDisplay(BusinessChannelOverride businessChannelOverride)
 {
     var dictionaryInstance = new DictionaryInstance()
     {
         CultureCode = ROOT,
         Content = businessChannelOverride.DisplayCommission ?? String.Empty,
         Item = new DictionaryDataItem()
         {
             ItemKey =
                 string.Format(DictionaryConstants.BUSINESS_CHANNEL_OVERRIDE_DISPLAY_COMMISION,
                               businessChannelOverride.Id)
         }
     };
     dictionaryDao.UpsertDictionaryInstance(dictionaryInstance);
     businessChannelOverride.DctCommissionDisplay = dictionaryInstance.ItemId;
     businessChannelOverrideDao.Modify(businessChannelOverride);
 }
Example #4
0
        /// <summary>
        /// Set the override values according to claims
        /// </summary>
        /// <param name="businessChannelOverride">new override object</param>
        /// <param name="modifyVisible">true if it can modify the visibility</param>
        /// <param name="modifyCommissions">true if it can modify the commission</param>
        /// <param name="oldBusinessChannelOverride">old override object</param>
        private static void SetOverrideValues(BusinessChannelOverride businessChannelOverride, bool modifyVisible,
                                              bool modifyCommissions, BusinessChannelOverride oldBusinessChannelOverride)
        {
            //Keep the visible value intact if the user cannot modify it
            if (!modifyVisible)
            {
                businessChannelOverride.IsVisible = oldBusinessChannelOverride.IsVisible;
            }

            //Keep the commission values intact if the user cannot modify them
            if (!modifyCommissions)
            {
                businessChannelOverride.EviivoCommission = oldBusinessChannelOverride.EviivoCommission;
                businessChannelOverride.DistributorCommission = oldBusinessChannelOverride.DistributorCommission;
                businessChannelOverride.DisplayCommission = oldBusinessChannelOverride.DisplayCommission;
            }
            
        }
Example #5
0
        /// <summary>
        /// Modify business channel override
        /// </summary>
        /// <param name="businessChannelOverride">BusinessChannelOverride to update</param>
        /// <param name="modifyVisible">modifyVisible</param>
        /// <param name="modifyCommissions">modifyCommissions</param>
        public void ModifyBusinessChannelOverride(BusinessChannelOverride businessChannelOverride, bool modifyVisible, bool modifyCommissions)
        {
            using (var tx = new BusinessTransaction())
            {
                //Values needed for the previous Business Channel Override
                var oldBusinessChannelOverride = businessChannelOverrideDao.GetById(businessChannelOverride.Id);

                oldBusinessChannelOverride.Channel = channelDao.GetById(businessChannelOverride.ChannelId);
                oldBusinessChannelOverride.Business = businessDao.GetByKey(businessChannelOverride.BusinessId);

                SetOverrideValues(businessChannelOverride, modifyVisible, modifyCommissions, oldBusinessChannelOverride);

                //opted out if was opted in and now is not visible
                if (businessChannelOverride.IsVisible == false)
                {
                    businessChannelOptInDao.RemoveByChannelAndBusiness(businessChannelOverride.BusinessId, businessChannelOverride.ChannelId);
                }

                businessChannelOverrideDao.Modify(businessChannelOverride);

                UpsertCommissionDisplay(businessChannelOverride);

                var channelName = oldBusinessChannelOverride.Channel.Name;

                // Record business event
                if (!businessChannelOverride.HasSameVisibility(oldBusinessChannelOverride))
                {
                    eventTrackingManager.CreateBusinessEventAsync(businessChannelOverride.BusinessId,
                                                             BusinessEventTypesEnum.ChannelSettingUpdated,
                                                             businessChannelOverride.ChannelId.ToString(),
                                                             String.Format("{0}: Set channel to {1}",
                                                                           channelName,
                                                                           businessChannelOverride.IsVisible == true
                                                                               ? "visible"
                                                                               : "hidden"));
                }

                //Send CRM email message
                //if both overrides are the same, we don't bother
                if (!businessChannelOverride.HasSameCommissions(oldBusinessChannelOverride))
                {
                    eventTrackingManager.CreateBusinessEventAsync(businessChannelOverride.BusinessId,
                                                             BusinessEventTypesEnum.ChannelSettingUpdated,
                                                             businessChannelOverride.ChannelId.ToString(),
                                                             String.Format("{0}: Edit Business Commission", channelName));

                    emailManager.SendCommissionUpdateEmail(businessChannelOverride, oldBusinessChannelOverride);
                }

                tx.Commit();
            }
        }
Example #6
0
        /// <summary>
        /// Create business channel override
        /// </summary>
        /// <param name="modifyVisible">modifyVisible</param>
        /// <param name="modifyCommissions">modifyCommissions</param>
        /// <param name="businessChannelOverride">businessChannelOverride to create</param>
        public void CreateBusinessChannelOverride(BusinessChannelOverride businessChannelOverride, bool modifyVisible, bool modifyCommissions)
        {
            using (var tx = new BusinessTransaction())
            {
                //Values needed for the previous BCO
                var channel = channelDao.GetById(businessChannelOverride.ChannelId);
                var business = businessDao.GetByKey(businessChannelOverride.BusinessId);
                var oldBusinessChannelOverride = new BusinessChannelOverride()
                 {
                     DisplayCommission = channel.CommissionDisplay,
                     DistributorCommission = channel.DistributorCommission,
                     EviivoCommission = channel.EviivoCommission,
                     Business = business,
                     Channel = channel
                 };

                SetOverrideValues(businessChannelOverride, modifyVisible, modifyCommissions, oldBusinessChannelOverride);

                //opted out if was opted in and now is not visible
                if (businessChannelOverride.IsVisible == false)
                {
                    businessChannelOptInDao.RemoveByChannelAndBusiness(businessChannelOverride.BusinessId, businessChannelOverride.ChannelId);
                }

                businessChannelOverrideDao.Create(businessChannelOverride);

                UpsertCommissionDisplay(businessChannelOverride);

                // Record business events and sending mail
                if (!businessChannelOverride.HasSameVisibility(oldBusinessChannelOverride))
                {
                    eventTrackingManager.CreateBusinessEventAsync(businessChannelOverride.BusinessId,
                                                             BusinessEventTypesEnum.ChannelSettingUpdated,
                                                             businessChannelOverride.ChannelId.ToString(),
                                                             String.Format("{0}: Set channel to {1}",
                                                                           channel.Name,
                                                                           businessChannelOverride.IsVisible == true
                                                                               ? "visible"
                                                                               : "hidden"));
                }

                if (businessChannelOverride.DistributorCommission != null ||
                    businessChannelOverride.EviivoCommission != null ||
                    businessChannelOverride.DisplayCommission != null)
                {
                    eventTrackingManager.CreateBusinessEventAsync(businessChannelOverride.BusinessId,
                                                             BusinessEventTypesEnum.ChannelSettingUpdated,
                                                             businessChannelOverride.ChannelId.ToString(),
                                                             String.Format("{0}: Edit Business Commission", channel.Name));

                    emailManager.SendCommissionUpdateEmail(businessChannelOverride, oldBusinessChannelOverride);
                }

                tx.Commit();
            }
        }
        /// <summary>
        /// Modify a BusinessChannel record
        /// </summary>
        /// <param name="businessChannel">The BusinessChannel to create</param>
        public void Modify(BusinessChannelOverride businessChannel)
        {
            const string SQL_STATEMENT = @"
                UPDATE Distribution.BusinessChannelOverride
                   SET BusinessId = @BusinessId,
                       ChannelId = @ChannelId,
                       DistributorCommission = @DistributorCommission,
                       EviivoCommission = @EviivoCommission,
                       UpdatedDatetime = @UpdatedDatetime,
                       UpdatedByUserId = @UpdatedByUserId,
                       DctCommissionDisplay = @DctCommissionDisplay,
                       IsVisible = @IsVisible,
                       [email protected]
                    WHERE @Id = Id
                SELECT @RC = @@ROWCOUNT";

            SqlParameter outputKey;
            var parameters = new List<SqlParameter>
                {
                    DbHelper.CreateParameter(BusinessChannelOverrideMapper.Parameters.BusinessId, businessChannel.BusinessId),
                    DbHelper.CreateParameter(BusinessChannelOverrideMapper.Parameters.ChannelId, businessChannel.ChannelId),
                    DbHelper.CreateParameter(BusinessChannelOverrideMapper.Parameters.DistributorCommission, businessChannel.DistributorCommission),
                    DbHelper.CreateParameter(BusinessChannelOverrideMapper.Parameters.EviivoCommission, businessChannel.EviivoCommission),
                    DbHelper.CreateParameter(BusinessChannelOverrideMapper.Parameters.UpdatedDatetime, DateTime.UtcNow),
                    DbHelper.CreateParameter(BusinessChannelOverrideMapper.Parameters.DctCommissionDisplay, businessChannel.DctCommissionDisplay),
                    DbHelper.CreateParameter(BusinessChannelOverrideMapper.Parameters.IsVisible, businessChannel.IsVisible),
                    DbHelper.CreateParameter(BusinessChannelOverrideMapper.Parameters.Id, businessChannel.Id),
                       DbHelper.CreateParameter(BusinessChannelOverrideMapper.Parameters.CurrencyCode, businessChannel.CurrencyCode)
                };

            parameters.Add(outputKey = DbHelper.CreateParameterOut<int>(ROW_COUNT, SqlDbType.Int));

            // Add auditing parameters
            AuditFieldsHelper.PopulateAuditFields(parameters);

            DbHelper.ExecuteNonQueryCommand(SQL_STATEMENT, parameters: parameters);

            // Make sure the record was updated
            if (outputKey.Value == DBNull.Value)
            {
                throw new PrimaryKeyNotSetException(ErrorFactory.CreateAndLogError(Errors.SRVEX30027, "BusinessChannelOverride",
                    additionalDescriptionParameters: (new object[] { businessChannel.BusinessId, businessChannel.ChannelId })));
            }

        }
Example #8
0
        /// <summary>
        /// Prepare an email template and send the email for commission changes
        /// </summary>
        /// <param name="businessChannelOverride">The business channel override</param>
        /// <param name="oldBusinessChannelOverride">The old business channel override</param>
        /// <returns>true if email was sent</returns>
        public bool SendCommissionUpdateEmail(BusinessChannelOverride businessChannelOverride, BusinessChannelOverride oldBusinessChannelOverride)
        {
            var commissionUpdateEmail = GetEviivoEmailByType(InternalEmailAddressType.CommissionUpdate);

            var emailToSend = new EmailDto
                {
                    Priority = new EmailPriorityDto { Priority = EmailPriorityEnumDto.Normal },
                    User = GetEmailUser(),
                    SenderEmail = commissionUpdateEmail,
                    ReplyToEmail = commissionUpdateEmail,
                    Recipients = GetEviivoEmailsByType(InternalEmailAddressType.Contracts),
                    Subject = string.Format(EmailTexts.Commission_Subject,
                                            oldBusinessChannelOverride.Business.ShortName,
                                            oldBusinessChannelOverride.Channel.ShortName)
                };

            var eviivoCommision = businessChannelOverride.EviivoCommission.HasValue ? businessChannelOverride.EviivoCommission.Value : 0;
            var distributorCommission = businessChannelOverride.DistributorCommission.HasValue ? businessChannelOverride.DistributorCommission.Value : 0;
            var oldEviivoCommision = oldBusinessChannelOverride.EviivoCommission.HasValue ? oldBusinessChannelOverride.EviivoCommission.Value : 0;
            var oldDistributorCommission = oldBusinessChannelOverride.DistributorCommission.HasValue ? oldBusinessChannelOverride.DistributorCommission.Value : 0;
            var commisionText = !businessChannelOverride.EviivoCommission.HasValue && !businessChannelOverride.DistributorCommission.HasValue ?
                                EmailTexts.DefaultChannelCommission : 
                                (eviivoCommision + distributorCommission).ToString("F");
            var oldCommisionText = !oldBusinessChannelOverride.EviivoCommission.HasValue && !oldBusinessChannelOverride.DistributorCommission.HasValue ?
                                    EmailTexts.DefaultChannelCommission :
                                    (oldEviivoCommision + oldDistributorCommission).ToString("F");
            var utcNow = DateTime.UtcNow;

            var parameters = new Dictionary<string, string>
                {
                    {LABEL_PROPERTY_NAME, EmailTexts.PropetyName},
                    {LABEL_CHANNEL_NAME, EmailTexts.ChannelShortName},
                    {LABEL_NEW_VALUE, EmailTexts.NewValue},
                    {LABEL_PREV_VALUE, EmailTexts.PrevValue},
                    {LABEL_COMMISSION, EmailTexts.Commission},
                    {LABEL_UPDATED_BY, EmailTexts.UpdatedBy},
                    {LABEL_UPDATED_AT, EmailTexts.UpdatedAt},
                    {LABEL_DISPLAYED_COMMISSION, EmailTexts.DisplayedCommission},
                    {BUSINESS_NAME, oldBusinessChannelOverride.Business.Name},
                    {CHANNEL_NAME, oldBusinessChannelOverride.Channel.ShortName},
                    {CHANNEL_OVERRIDE_UPDATED_BY, GetUserName()},
                    {CHANNEL_OVERRIDE_UPDATED_AT, string.Format("{0} {1}",utcNow.ToShortDateString(),utcNow.ToShortTimeString())},
                    {NEW_VALUE_COMMISSION, commisionText},
                    {NEW_VALUE_DISPLAYED_COMMISSION, businessChannelOverride.DisplayCommission ?? EmailTexts.DefaultChannelDisplay},
                    {PREV_VALUE_COMMISSION, oldCommisionText},
                    {PREV_VALUE_DISPLAYED_COMMISSION, oldBusinessChannelOverride.DisplayCommission ?? EmailTexts.DefaultChannelDisplay},
                };

            emailToSend.Bodies = new List<EmailBodyDto>
                {
                    new EmailBodyDto
                        {
                            Content = FormatTemplateLabels(HtmlTemplates.EmailTemplate_Commission, parameters),
                            MimeType = EmailMimeTypeEnumDto.Html
                        }
                };

            return SendEmailAction(emailToSend, COMMISSION, oldBusinessChannelOverride.Business.ShortName);
        }
Example #9
0
 /// <summary>
 /// Returns true if both the new and old override have the same commission
 /// </summary>
 /// <param name="oldBusinessChannelOverride">latest BusinessChannelOverride</param>
 /// <returns>True if both are the same regarding the comissions</returns>
 public bool HasSameCommissions(BusinessChannelOverride oldBusinessChannelOverride)
 {
     return (this.DisplayCommission ?? string.Empty) == (oldBusinessChannelOverride.DisplayCommission ?? string.Empty)
            && (this.DistributorCommission ?? 0) == (oldBusinessChannelOverride.DistributorCommission ?? 0)
            && (this.EviivoCommission ?? 0) == (oldBusinessChannelOverride.EviivoCommission ?? 0);
 }
Example #10
0
 /// <summary>
 /// Returns true if both the new and old override have the same visibility
 /// </summary>
 /// <param name="oldBusinessChannelOverride">latest BusinessChannelOverride</param>
 /// <returns>True if both have the same visibility</returns>
 public bool HasSameVisibility(BusinessChannelOverride oldBusinessChannelOverride)
 {
     return this.IsVisible == oldBusinessChannelOverride.IsVisible;
 }
            public void UpdateWithCorrectArgumentIsSuccessful()
            {
                // Arrange
                long businessChannelOverrideId;
                var businessChannelOverride = new BusinessChannelOverride()
                {
                    DisplayCommission = "Display Commission test",
                    IsVisible = false,
                    BusinessId = 1,
                    ChannelId = channelDao.GetChannelIdByShortName("toprooms").Value,
                    EviivoCommission = 20,
                    DistributorCommission = 30
                };
                businessChannelOverrideDao.Create(businessChannelOverride);
                businessChannelOverrideId = businessChannelOverride.Id;

                businessChannelOverride = businessChannelOverrideDao.GetById(businessChannelOverrideId);
                var businessChannelOverrideUpdClone = new BusinessChannelOverride()
                {
                    Id = businessChannelOverride.Id,
                    BusinessId = businessChannelOverride.BusinessId,
                    ChannelId = businessChannelOverride.ChannelId,
                    DisplayCommission = businessChannelOverride.DisplayCommission,
                    DistributorCommission = businessChannelOverride.DistributorCommission,
                    EviivoCommission = businessChannelOverride.EviivoCommission,
                    IsVisible = businessChannelOverride.IsVisible
                };

                businessChannelOverride.EviivoCommission++;
                businessChannelOverride.DistributorCommission++;
                businessChannelOverride.DisplayCommission = businessChannelOverride.DisplayCommission + " updated";
                businessChannelOverride.IsVisible = !businessChannelOverride.IsVisible;

                // Act
                businessChannelOverrideDao.Modify(businessChannelOverride);
                var businessChannelOverrideUpd = businessChannelOverrideDao.GetById(businessChannelOverrideId);

                // Assert
                Assert.IsTrue(businessChannelOverrideUpd.EviivoCommission != businessChannelOverrideUpdClone.EviivoCommission
                              && businessChannelOverrideUpd.DistributorCommission != businessChannelOverrideUpdClone.DistributorCommission
                              && businessChannelOverrideUpd.IsVisible != businessChannelOverrideUpdClone.IsVisible, "Expected different values.");

            }
            public void GetByIdWithExistingBusinessChannelOverrideIsSuccessful()
            {
                // Arrange
                long businessChannelOverrideId;
                var businessChannelOverride = new BusinessChannelOverride()
                {
                    DisplayCommission = "Display Commission test",
                    IsVisible = false,
                    BusinessId = 1,
                    ChannelId = channelDao.GetChannelIdByShortName("toprooms").Value,
                    EviivoCommission = 20,
                    DistributorCommission = 30
                };
                businessChannelOverrideDao.Create(businessChannelOverride);
                businessChannelOverrideId = businessChannelOverride.Id;

                // Act
                businessChannelOverride = businessChannelOverrideDao.GetById(businessChannelOverrideId);

                // Assert
                Assert.IsNotNull(businessChannelOverride, "Expected business channel override record.");

            }
Example #13
0
            public void ModifyBusinessChannelOverrideWithCorrectArgumentsIsSuccessful()
            {
                //Arrange
                var businessChannelOverrideDao = MockRepository.GenerateMock<IBusinessChannelOverrideDao>();
                var channelDao = MockRepository.GenerateMock<IChannelDao>();
                var businessDao = MockRepository.GenerateMock<IBusinessDao>();
                var businessChannelOptInDao = MockRepository.GenerateMock<IBusinessChannelOptInDao>();

                var distributionManager = MockRepository.GeneratePartialMock<DistributionManager>();
                var eventTrackingManager = MockRepository.GenerateMock<IEventTrackingManager>();
                var emailManager = MockRepository.GenerateMock<IEmailManager>();

                var businessChannelOverrideId = default(long);
                var distributorCommission = 10;
                var eviivoCommission = 10;
                var visible = false;
                var businessId = 1;
                var channelId = 1;
                var commissionDisplay = "test commission display";

                var modifyCommissions = true;
                var modifyVisible = true;

                var oldBusinessChannelOverride = new BusinessChannelOverride()
                {
                    Id = businessChannelOverrideId,
                    BusinessId = businessId,
                    ChannelId = channelId,
                    DistributorCommission = distributorCommission,
                    EviivoCommission = eviivoCommission,
                    DisplayCommission = commissionDisplay,
                    IsVisible = visible
                };
                var newBusinessChannelOverride = new BusinessChannelOverride()
                {
                    Id = businessChannelOverrideId,
                    BusinessId = businessId,
                    ChannelId = channelId,
                    DistributorCommission = distributorCommission + 10,
                    EviivoCommission = eviivoCommission + 10,
                    DisplayCommission = commissionDisplay + " display",
                    IsVisible = false
                };

                businessChannelOverrideDao.Stub(bco => bco.GetById(businessChannelOverrideId))
                                   .Return(oldBusinessChannelOverride);
                channelDao.Stub(c => c.GetById(channelId)).Return(new Channel()
                {
                    Id = channelId,
                    DistributorCommission = distributorCommission,
                    EviivoCommission = eviivoCommission,
                    CommissionDisplay = commissionDisplay,
                    ShortName = "toprooms"
                });

                businessDao.Stub(b => b.GetByKey(oldBusinessChannelOverride.BusinessId)).Return(new Model.Business.Business()
                {
                    ShortName = "test business",
                    Id = businessId
                });

                businessDao.Stub(b => b.IsBusinessVisibleForChannel(newBusinessChannelOverride.ChannelId, newBusinessChannelOverride.BusinessId)).Return(true);

                businessChannelOptInDao.Stub(
                    bcoi =>
                    bcoi.RemoveByChannelAndBusiness(newBusinessChannelOverride.BusinessId,
                                                    newBusinessChannelOverride.ChannelId)).Return(true);

                businessChannelOverrideDao.Stub(
                    bco =>
                    bco.Modify(Arg<BusinessChannelOverride>.Is.Equal(newBusinessChannelOverride)));

                eventTrackingManager.Stub(
                    etm =>
                    etm.CreateBusinessEventAsync(businessId, BusinessEventTypesEnum.ChannelSettingUpdated,
                                            channelId.ToString(), "Hidden"));

                emailManager.Stub(
                    em => em.SendCommissionUpdateEmail(newBusinessChannelOverride, oldBusinessChannelOverride))
                            .Return(true);

                distributionManager.BusinessDao = businessDao;
                distributionManager.ChannelDao = channelDao;
                distributionManager.EventTrackingManager = eventTrackingManager;
                distributionManager.EmailManager = emailManager;
                distributionManager.BusinessChannelOverrideDao = businessChannelOverrideDao;
                distributionManager.BusinessChannelOptInDao = businessChannelOptInDao;

                //Act
                distributionManager.ModifyBusinessChannelOverride(newBusinessChannelOverride, modifyVisible, modifyCommissions);

                //Assert
                businessDao.AssertWasCalled(bdao => bdao.GetByKey(newBusinessChannelOverride.BusinessId));
                businessChannelOverrideDao.AssertWasCalled(bco => bco.Modify(newBusinessChannelOverride));
                channelDao.AssertWasCalled(c => c.GetById(channelId));
                businessChannelOptInDao.AssertWasCalled(bcoi => bcoi.RemoveByChannelAndBusiness(newBusinessChannelOverride.BusinessId, newBusinessChannelOverride.ChannelId));
                eventTrackingManager.AssertWasCalled(etm => etm.CreateBusinessEventAsync(businessId, BusinessEventTypesEnum.ChannelSettingUpdated, channelId.ToString(), "Channel visibility: Hidden"));
                emailManager.AssertWasCalled(em => em.SendCommissionUpdateEmail(Arg<BusinessChannelOverride>.Is.Anything, Arg<BusinessChannelOverride>.Is.Anything));

            }