public GetCampaignResponse GetCampaign(GetCampaignRequest request) { var result = new ServerGetCampaignResponse(); var returnValue = result.ProcessRequest(cnn, request); return(returnValue); }
public async Task <BaseResponseDto <List <CampaignDto> > > Handle(GetCampaignRequest request, CancellationToken cancellationToken) { BaseResponseDto <List <CampaignDto> > response = new BaseResponseDto <List <CampaignDto> >(); try { List <CampaignDto> campaign = (await _repository.GetWhereAsync(c => c.CampaignName == request.campaignName)).Select(c => new CampaignDto { Duration = c.Duration, Limit = c.Limit, CampaignName = c.CampaignName, ProductCode = c.ProductCode, TargetSalesCount = c.TargetSalesCount }).ToList(); response.Data = campaign; } catch (Exception ex) { _logger.LogError(ex, ex.Message); response.Errors.Add("An error occurred while getting campaign."); } return(response); }
public void GetCampaign_SearchWithCampaignIdThatDoesNotExist_CampaignNotFoundException() { mockCampaignRepository.Setup(tr => tr.GetCampaignById(It.IsAny <int>())).Throws(new InvalidOperationException("Campaign doesn't exist")); GetCampaignRequest request = new GetCampaignRequest(ILLEGAL_CAMPAIGN_ID); GetCampaignResponse response = new GetCampaignResponse(); response = campaignService.GetCampaign(request); mockRepository.VerifyAll(); Assert.AreEqual("Campaign doesn't exist", response.Exception.Message); }
public HttpResponseMessage GetCampaign(int campaignId) { GetCampaignRequest request = new GetCampaignRequest(campaignId) { RequestedBy = this.UserId, AccountId = this.AccountId, RoleId = this.RoleId }; GetCampaignResponse response = campaignService.GetCampaign(request); return(Request.BuildResponse(response)); }
/// <summary>Snippet for GetCampaign</summary> /// <remarks> /// This snippet has been automatically generated for illustrative purposes only. /// It may require modifications to work in your environment. /// </remarks> public void GetCampaignRequestObject() { // Create client CampaignServiceClient campaignServiceClient = CampaignServiceClient.Create(); // Initialize request argument(s) GetCampaignRequest request = new GetCampaignRequest { ResourceNameAsCampaignName = CampaignName.FromCustomerCampaign("[CUSTOMER_ID]", "[CAMPAIGN_ID]"), }; // Make the request Campaign response = campaignServiceClient.GetCampaign(request); }
/// <summary>Snippet for GetCampaignAsync</summary> /// <remarks> /// This snippet has been automatically generated for illustrative purposes only. /// It may require modifications to work in your environment. /// </remarks> public async Task GetCampaignRequestObjectAsync() { // Create client CampaignServiceClient campaignServiceClient = await CampaignServiceClient.CreateAsync(); // Initialize request argument(s) GetCampaignRequest request = new GetCampaignRequest { ResourceNameAsCampaignName = CampaignName.FromCustomerCampaign("[CUSTOMER]", "[CAMPAIGN]"), }; // Make the request Campaign response = await campaignServiceClient.GetCampaignAsync(request); }
public void GetCampaign_SearchWithCampaignId_ReturnCampaignSuccessfully() { Campaign campaign = CampaignMockData.CreateCampaignWithCustomValues(mockRepository, 5, "Test", new DateTime(2012, 1, 1) , "*****@*****.**", 5, Entities.CampaignStatus.Draft, sampleLayout, "Test campaign", "", 1); mockCampaignRepository.Setup(tr => tr.GetCampaignById(It.IsAny <int>())).Returns(campaign); GetCampaignResponse response = new GetCampaignResponse(); GetCampaignRequest request = new GetCampaignRequest(LEGAL_CAMPAIGN_ID); response = campaignService.GetCampaign(request); mockRepository.VerifyAll(); Assert.AreEqual(campaign.Id, response.CampaignViewModel.CampaignID); }
/// <summary>Snippet for GetCampaignAsync</summary> public async Task GetCampaignRequestObjectAsync() { // Snippet: GetCampaignAsync(GetCampaignRequest, CallSettings) // Additional: GetCampaignAsync(GetCampaignRequest, CancellationToken) // Create client CampaignServiceClient campaignServiceClient = await CampaignServiceClient.CreateAsync(); // Initialize request argument(s) GetCampaignRequest request = new GetCampaignRequest { ResourceNameAsCampaignName = CampaignName.FromCustomerCampaign("[CUSTOMER]", "[CAMPAIGN]"), }; // Make the request Campaign response = await campaignServiceClient.GetCampaignAsync(request); // End snippet }
public void GetCampaign2() { Mock <CampaignService.CampaignServiceClient> mockGrpcClient = new Mock <CampaignService.CampaignServiceClient>(MockBehavior.Strict); GetCampaignRequest request = new GetCampaignRequest { ResourceName = new CampaignName("[CUSTOMER]", "[CAMPAIGN]").ToString(), }; Campaign expectedResponse = new Campaign { ResourceName = "resourceName2625949903", }; mockGrpcClient.Setup(x => x.GetCampaign(request, It.IsAny <CallOptions>())) .Returns(expectedResponse); CampaignServiceClient client = new CampaignServiceClientImpl(mockGrpcClient.Object, null); Campaign response = client.GetCampaign(request); Assert.AreEqual(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public async Task GetCampaignAsync2() { Mock <CampaignService.CampaignServiceClient> mockGrpcClient = new Mock <CampaignService.CampaignServiceClient>(MockBehavior.Strict); GetCampaignRequest request = new GetCampaignRequest { ResourceName = new CampaignName("[CUSTOMER]", "[CAMPAIGN]").ToString(), }; Campaign expectedResponse = new Campaign { ResourceName = "resourceName2625949903", }; mockGrpcClient.Setup(x => x.GetCampaignAsync(request, It.IsAny <CallOptions>())) .Returns(new Grpc.Core.AsyncUnaryCall <Campaign>(Task.FromResult(expectedResponse), null, null, null, null)); CampaignServiceClient client = new CampaignServiceClientImpl(mockGrpcClient.Object, null); Campaign response = await client.GetCampaignAsync(request); Assert.AreEqual(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public async stt::Task GetCampaignResourceNamesAsync() { moq::Mock <CampaignService.CampaignServiceClient> mockGrpcClient = new moq::Mock <CampaignService.CampaignServiceClient>(moq::MockBehavior.Strict); GetCampaignRequest request = new GetCampaignRequest { ResourceNameAsCampaignName = gagvr::CampaignName.FromCustomerCampaign("[CUSTOMER]", "[CAMPAIGN]"), }; gagvr::Campaign expectedResponse = new gagvr::Campaign { ResourceNameAsCampaignName = gagvr::CampaignName.FromCustomerCampaign("[CUSTOMER]", "[CAMPAIGN]"), Id = -6774108720365892680L, CampaignName = gagvr::CampaignName.FromCustomerCampaign("[CUSTOMER]", "[CAMPAIGN]"), Status = gagve::CampaignStatusEnum.Types.CampaignStatus.Removed, CampaignBudgetAsCampaignBudgetName = gagvr::CampaignBudgetName.FromCustomerCampaignBudget("[CUSTOMER]", "[CAMPAIGN_BUDGET]"), AdServingOptimizationStatus = gagve::AdServingOptimizationStatusEnum.Types.AdServingOptimizationStatus.ConversionOptimize, AdvertisingChannelType = gagve::AdvertisingChannelTypeEnum.Types.AdvertisingChannelType.MultiChannel, AdvertisingChannelSubType = gagve::AdvertisingChannelSubTypeEnum.Types.AdvertisingChannelSubType.VideoOutstream, TrackingUrlTemplate = "tracking_url_template157f152a", UrlCustomParameters = { new gagvc::CustomParameter(), }, NetworkSettings = new gagvr::Campaign.Types.NetworkSettings(), ExperimentType = gagve::CampaignExperimentTypeEnum.Types.CampaignExperimentType.Unknown, StartDate = "start_date11b9dbea", EndDate = "end_date89dae890", ServingStatus = gagve::CampaignServingStatusEnum.Types.CampaignServingStatus.Ended, BiddingStrategyType = gagve::BiddingStrategyTypeEnum.Types.BiddingStrategyType.TargetCpa, BiddingStrategyAsBiddingStrategyName = gagvr::BiddingStrategyName.FromCustomerBiddingStrategy("[CUSTOMER]", "[BIDDING_STRATEGY]"), ManualCpc = new gagvc::ManualCpc(), ManualCpm = new gagvc::ManualCpm(), TargetCpa = new gagvc::TargetCpa(), TargetSpend = new gagvc::TargetSpend(), BaseCampaignAsCampaignName = gagvr::CampaignName.FromCustomerCampaign("[CUSTOMER]", "[CAMPAIGN]"), TargetRoas = new gagvc::TargetRoas(), MaximizeConversions = new gagvc::MaximizeConversions(), MaximizeConversionValue = new gagvc::MaximizeConversionValue(), HotelSetting = new gagvr::Campaign.Types.HotelSettingInfo(), DynamicSearchAdsSetting = new gagvr::Campaign.Types.DynamicSearchAdsSetting(), PercentCpc = new gagvc::PercentCpc(), ShoppingSetting = new gagvr::Campaign.Types.ShoppingSetting(), ManualCpv = new gagvc::ManualCpv(), FinalUrlSuffix = "final_url_suffix046ed37a", RealTimeBiddingSetting = new gagvc::RealTimeBiddingSetting(), FrequencyCaps = { new gagvc::FrequencyCapEntry(), }, TargetCpm = new gagvc::TargetCpm(), VideoBrandSafetySuitability = gagve::BrandSafetySuitabilityEnum.Types.BrandSafetySuitability.Unknown, TargetingSetting = new gagvc::TargetingSetting(), VanityPharma = new gagvr::Campaign.Types.VanityPharma(), SelectiveOptimization = new gagvr::Campaign.Types.SelectiveOptimization(), TrackingSetting = new gagvr::Campaign.Types.TrackingSetting(), GeoTargetTypeSetting = new gagvr::Campaign.Types.GeoTargetTypeSetting(), TargetImpressionShare = new gagvc::TargetImpressionShare(), Commission = new gagvc::Commission(), AppCampaignSetting = new gagvr::Campaign.Types.AppCampaignSetting(), PaymentMode = gagve::PaymentModeEnum.Types.PaymentMode.Clicks, LabelsAsCampaignLabelNames = { gagvr::CampaignLabelName.FromCustomerCampaignLabel("[CUSTOMER]", "[CAMPAIGN_LABEL]"), }, OptimizationScore = -4.7741588361660064E+17, }; mockGrpcClient.Setup(x => x.GetCampaignAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <gagvr::Campaign>(stt::Task.FromResult(expectedResponse), null, null, null, null)); CampaignServiceClient client = new CampaignServiceClientImpl(mockGrpcClient.Object, null); gagvr::Campaign responseCallSettings = await client.GetCampaignAsync(request.ResourceNameAsCampaignName, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); Assert.AreEqual(expectedResponse, responseCallSettings); gagvr::Campaign responseCancellationToken = await client.GetCampaignAsync(request.ResourceNameAsCampaignName, st::CancellationToken.None); Assert.AreEqual(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
public void GetCampaignRequestObject() { moq::Mock <CampaignService.CampaignServiceClient> mockGrpcClient = new moq::Mock <CampaignService.CampaignServiceClient>(moq::MockBehavior.Strict); GetCampaignRequest request = new GetCampaignRequest { ResourceNameAsCampaignName = gagvr::CampaignName.FromCustomerCampaign("[CUSTOMER_ID]", "[CAMPAIGN_ID]"), }; gagvr::Campaign expectedResponse = new gagvr::Campaign { ResourceNameAsCampaignName = gagvr::CampaignName.FromCustomerCampaign("[CUSTOMER_ID]", "[CAMPAIGN_ID]"), Status = gagve::CampaignStatusEnum.Types.CampaignStatus.Removed, AdServingOptimizationStatus = gagve::AdServingOptimizationStatusEnum.Types.AdServingOptimizationStatus.ConversionOptimize, AdvertisingChannelType = gagve::AdvertisingChannelTypeEnum.Types.AdvertisingChannelType.Unknown, AdvertisingChannelSubType = gagve::AdvertisingChannelSubTypeEnum.Types.AdvertisingChannelSubType.Unknown, UrlCustomParameters = { new gagvc::CustomParameter(), }, NetworkSettings = new gagvr::Campaign.Types.NetworkSettings(), ExperimentType = gagve::CampaignExperimentTypeEnum.Types.CampaignExperimentType.Unknown, ServingStatus = gagve::CampaignServingStatusEnum.Types.CampaignServingStatus.Ended, BiddingStrategyType = gagve::BiddingStrategyTypeEnum.Types.BiddingStrategyType.PercentCpc, ManualCpc = new gagvc::ManualCpc(), ManualCpm = new gagvc::ManualCpm(), TargetCpa = new gagvc::TargetCpa(), TargetSpend = new gagvc::TargetSpend(), TargetRoas = new gagvc::TargetRoas(), MaximizeConversions = new gagvc::MaximizeConversions(), MaximizeConversionValue = new gagvc::MaximizeConversionValue(), HotelSetting = new gagvr::Campaign.Types.HotelSettingInfo(), DynamicSearchAdsSetting = new gagvr::Campaign.Types.DynamicSearchAdsSetting(), PercentCpc = new gagvc::PercentCpc(), ShoppingSetting = new gagvr::Campaign.Types.ShoppingSetting(), ManualCpv = new gagvc::ManualCpv(), RealTimeBiddingSetting = new gagvc::RealTimeBiddingSetting(), FrequencyCaps = { new gagvc::FrequencyCapEntry(), }, TargetCpm = new gagvc::TargetCpm(), VideoBrandSafetySuitability = gagve::BrandSafetySuitabilityEnum.Types.BrandSafetySuitability.Unknown, TargetingSetting = new gagvc::TargetingSetting(), VanityPharma = new gagvr::Campaign.Types.VanityPharma(), SelectiveOptimization = new gagvr::Campaign.Types.SelectiveOptimization(), TrackingSetting = new gagvr::Campaign.Types.TrackingSetting(), GeoTargetTypeSetting = new gagvr::Campaign.Types.GeoTargetTypeSetting(), TargetImpressionShare = new gagvc::TargetImpressionShare(), Commission = new gagvc::Commission(), LocalCampaignSetting = new gagvr::Campaign.Types.LocalCampaignSetting(), AppCampaignSetting = new gagvr::Campaign.Types.AppCampaignSetting(), PaymentMode = gagve::PaymentModeEnum.Types.PaymentMode.Clicks, OptimizationGoalSetting = new gagvr::Campaign.Types.OptimizationGoalSetting(), BaseCampaignAsCampaignName = gagvr::CampaignName.FromCustomerCampaign("[CUSTOMER_ID]", "[CAMPAIGN_ID]"), CampaignName = gagvr::CampaignName.FromCustomerCampaign("[CUSTOMER_ID]", "[CAMPAIGN_ID]"), Id = -6774108720365892680L, TrackingUrlTemplate = "tracking_url_template157f152a", LabelsAsCampaignLabelNames = { gagvr::CampaignLabelName.FromCustomerCampaignLabel("[CUSTOMER_ID]", "[CAMPAIGN_ID]", "[LABEL_ID]"), }, CampaignBudgetAsCampaignBudgetName = gagvr::CampaignBudgetName.FromCustomerCampaignBudget("[CUSTOMER_ID]", "[CAMPAIGN_BUDGET_ID]"), StartDate = "start_date11b9dbea", EndDate = "end_date89dae890", FinalUrlSuffix = "final_url_suffix046ed37a", OptimizationScore = -4.7741588361660064E+17, BiddingStrategyAsBiddingStrategyName = gagvr::BiddingStrategyName.FromCustomerBiddingStrategy("[CUSTOMER_ID]", "[BIDDING_STRATEGY_ID]"), ExcludedParentAssetFieldTypes = { gagve::AssetFieldTypeEnum.Types.AssetFieldType.HotelCallout, }, AccessibleBiddingStrategyAsAccessibleBiddingStrategyName = gagvr::AccessibleBiddingStrategyName.FromCustomerBiddingStrategy("[CUSTOMER_ID]", "[BIDDING_STRATEGY_ID]"), UrlExpansionOptOut = false, }; mockGrpcClient.Setup(x => x.GetCampaign(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); CampaignServiceClient client = new CampaignServiceClientImpl(mockGrpcClient.Object, null); gagvr::Campaign response = client.GetCampaign(request); Assert.AreEqual(expectedResponse, response); mockGrpcClient.VerifyAll(); }