public bool ModifyOptinChannelPrePaySettings(long businessId, BusinessChannelOptInDto businessChannelOptinDto) { CheckAccessRights(businessId); // Check if business id is valid if (Cache.Business.TryGetValue(businessId) == null) { throw new ValidationException(ErrorFactory.CreateAndLogError(Errors.SRVEX30001, "PropertyManagementSystemService.ModifyOptinChannelPrePaySettings", additionalDescriptionParameters: (new object[] { businessId }))); } var channelOptin = Mapper.Map<BusinessChannelOptIn>(businessChannelOptinDto); channelOptin.BusinessId = businessId; return distributionManager.UpdatePrePayForOptedInChannel(channelOptin); }
public bool ModifyOptinChannelCancellationPolicy(BusinessChannelOptInDto businessChannelOptinDto) { long businessId = businessChannelOptinDto.BusinessId ?? default(long); CheckAccessRights(businessId); // Check if business id is valid if (Cache.Business.TryGetValue(businessId) == null) { throw new ValidationException(ErrorFactory.CreateAndLogError(Errors.SRVEX30001, "PropertyManagementSystemService.GetAllDistributorsAndChannels", additionalDescriptionParameters: (new object[] { businessId }))); } BusinessChannelOptIn channelOptin = Mapper.Map<BusinessChannelOptIn>(businessChannelOptinDto); return distributionManager.UpdateCancellationForOptedInChannel(channelOptin); }
public void OptInToChannelForInvalidBusinessThrowsException() { // arrange const long BUSINESS_ID = -99; // BusinessId for UNKNOWN const string CULTURE_CODE = "en-GB"; var businessChannelOptInDto = new BusinessChannelOptInDto { BusinessId = BUSINESS_ID, ChannelId = 1, ChannelTermsId = 1 }; try { // act PropertyManagementSystemService.OptInToChannel(businessChannelOptInDto, CULTURE_CODE); // assert Assert.Fail("Validation Exception SRVEX30001 was expected but none was raised"); } catch (ValidationException ex) { Assert.AreEqual("SRVEX30001", ex.Code, "Check correct error code got returned"); } }
public void OptInToChannelWithValidInformationIsSuccessful() { //Arrange var distributionManager = MockRepository.GenerateStub<IDistributionManager>(); const long BUSINESS_ID = 1; const string CULTURE_CODE = "en-GB"; var businessChannelOptInDto = new BusinessChannelOptInDto { BusinessId = BUSINESS_ID, ChannelId = 1, ChannelTermsId = 1 }; PropertyManagementSystemService.DistributionManager = distributionManager; // Stub the BusinessCache to be used by our service method CacheHelper.StubBusinessCacheSingleBusiness(BUSINESS_ID); // invalidate the cache so we make sure our business is loaded into the cache Cache.Business.Invalidate(); //Act var businessChannelOptIn = PropertyManagementSystemService.OptInToChannel(businessChannelOptInDto, CULTURE_CODE); //Assert Assert.AreEqual(businessChannelOptInDto.BusinessId, businessChannelOptIn.BusinessId, "BusinessId doesn't match for businessChannelOptIn"); Assert.AreEqual(businessChannelOptInDto.ChannelId, businessChannelOptIn.ChannelId, "ChannelId doesn't match for businessChannelOptIn"); Assert.AreEqual(businessChannelOptInDto.ChannelTermsId, businessChannelOptIn.ChannelTermsId, "ChannelTermsId doesn't match for businessChannelOptIn"); //cleanup CacheHelper.ReAssignBusinessDaoToBusinessCache(); }
public void OptOutOfChannel(BusinessChannelOptInDto businessChannelOptInDto) { long businessId = businessChannelOptInDto.BusinessId.Value; CheckAccessRights(businessId); // Check if business id is valid if (Cache.Business.TryGetValue(businessId) == null) { throw new ValidationException(ErrorFactory.CreateAndLogError(Errors.SRVEX30001, "PropertyManagementSystemService.OptOutToChannel", additionalDescriptionParameters: (new object[] { businessId }))); } var businessChannelOptIn = Mapper.Map<BusinessChannelOptIn>(businessChannelOptInDto); distributionManager.OptOutOfChannel(businessChannelOptIn); }
public BusinessChannelOptInDto OptInToChannel(BusinessChannelOptInDto businessChannelOptInDto, string cultureCode) { long businessId = businessChannelOptInDto.BusinessId.Value; CheckAccessRights(businessId); // Check if business id is valid if (Cache.Business.TryGetValue(businessId) == null) { throw new ValidationException(ErrorFactory.CreateAndLogError(Errors.SRVEX30001, "PropertyManagementSystemService.OptInToChannel", additionalDescriptionParameters: (new object[] { businessId }))); } var businessChannelOptIn = Mapper.Map<BusinessChannelOptIn>(businessChannelOptInDto); if (businessChannelOptIn.ChannelId.HasValue) { var businessChannelOverrideView = distributionManager.GetBusinessChannelOverrideView(businessChannelOptIn.ChannelId.Value,businessChannelOptIn.BusinessId); if (businessChannelOverrideView != null) { if (string.IsNullOrEmpty(businessChannelOverrideView.CurrencyCode)) { businessChannelOptIn.CurrencyCode = businessChannelOverrideView.WorkingCurrencyCode; } else { businessChannelOptIn.CurrencyCode = businessChannelOverrideView.CurrencyCode; } } } else { Log.LogError("ChannelId should have a value."); } distributionManager.OptInToChannel(businessChannelOptIn, cultureCode); return Mapper.Map<BusinessChannelOptIn, BusinessChannelOptInDto>(businessChannelOptIn); }