Пример #1
0
 public Task CreateBrand(AdvertiserProduct brand)
 {
     brand.AdvertiserProductUuid = IdentityValue.GenerateNewId();
     brand.UtcCreatedDateTime    = _clock.UtcNow;
     _advertiserProductRepositoryAsync.Insert(brand);
     return(_brandscreenContext.SaveChangesAsync());
 }
Пример #2
0
 public Task CreateAdvertiser(Advertiser advertiser)
 {
     advertiser.AdvertiserUuid     = IdentityValue.GenerateNewId();
     advertiser.UtcCreatedDateTime = _clock.UtcNow;
     _advertiserRepositoryAsync.Insert(advertiser);
     return(_brandscreenContext.SaveChangesAsync());
 }
Пример #3
0
 public Task CreateCampaign(Campaign campaign)
 {
     campaign.CampaignUuid       = IdentityValue.GenerateNewId();
     campaign.UtcCreatedDateTime = _clock.UtcNow;
     _compaignAsyncRepository.Insert(campaign);
     return(_brandscreenContext.SaveChangesAsync());
 }
Пример #4
0
 public Task CreateSegment(Segment segment)
 {
     segment.RtbSegmentId       = IdentityValue.GenerateNewId();
     segment.SegmentStatusId    = (int)CampaignStatusEnum.Pending;
     segment.UtcCreatedDateTime = _clock.UtcNow;
     _segmentRepositoryAsync.Insert(segment);
     return(_brandscreenContext.SaveChangesAsync());
 }
Пример #5
0
        public async Task ModifyPlacement(PlacementModifyOptions options)
        {
            var placement = await _placementRepositoryAsync.Queryable()
                            .FirstOrDefaultAsync(x => x.Creative.CreativeUuid == options.CreativeUuid && x.AdGroup.AdGroupUuid == options.StrategyUuid);

            if (options.IsLinking)
            {
                // link
                if (placement == null)
                {
                    // create
                    var creative = await _creativeService.GetCreative(options.CreativeUuid);

                    var strategy = await _strategyService.GetStrategy(options.StrategyUuid);

                    placement = new Placement
                    {
                        PlacementUuid       = IdentityValue.GenerateNewId(),
                        CreativeId          = creative.CreativeId,
                        AdGroupId           = strategy.AdGroupId,
                        BuyerAccountId      = strategy.BuyerAccountId,
                        PlacementStatusId   = (int)CreativeStatusEnum.Live,
                        UtcCreatedDateTime  = _clock.UtcNow,
                        UtcModifiedDateTime = _clock.UtcNow
                    };
                    _placementRepositoryAsync.Insert(placement);
                }
                else
                {
                    // update
                    placement.IsDeleted           = false;
                    placement.PlacementStatusId   = (int)CreativeStatusEnum.Live;
                    placement.UtcModifiedDateTime = _clock.UtcNow;
                    _placementRepositoryAsync.Update(placement);
                }
                await _brandscreenContext.SaveChangesAsync();

                return;
            }

            // unlink
            if (placement != null && (!placement.IsDeleted || placement.PlacementStatusId != (int)CampaignStatusEnum.Deleted))
            {
                placement.IsDeleted           = true;
                placement.PlacementStatusId   = (int)CampaignStatusEnum.Deleted;
                placement.UtcModifiedDateTime = _clock.UtcNow;
                _placementRepositoryAsync.Update(placement);
                await _brandscreenContext.SaveChangesAsync();
            }
        }
Пример #6
0
 public async Task CreateAccount(BuyerAccount buyerAccount, User owner)
 {
     buyerAccount.BuyerAccountUuid          = IdentityValue.GenerateNewId();
     buyerAccount.CommercialContactUserId   = owner.UserId;
     buyerAccount.TermsConditionsAgreedDate = _clock.UtcNow;
     buyerAccount.UtcCreatedDateTime        = _clock.UtcNow;
     buyerAccount.UserBuyerRoles.Add(new UserBuyerRole
     {
         ObjectState    = ObjectState.Added,
         UserId         = owner.UserId,
         BuyerAccountId = buyerAccount.BuyerAccountId,
         RoleName       = StandardRole.Administrator,
         IsAccepted     = true,
         CostView       = (int)CostViewEnum.ClientCost
     });
     _buyerAccountRepositoryAsync.Insert(buyerAccount);
     await _brandscreenContext.SaveChangesAsync();
 }
Пример #7
0
        public async Task <Deal> CreateDeal(Deal deal)
        {
            var tmpDeal = await _dealRepositoryAsync.Queryable().FirstOrDefaultAsync(x => x.BuyerAccountId == deal.BuyerAccountId && x.PublisherId == deal.PublisherId && x.DealKey == deal.DealKey);

            if (tmpDeal != null)
            {
                if (tmpDeal.DealStatusId != (int)CampaignStatusEnum.Deleted)
                {
                    throw new BrandscreenException("Found duplicated deal key under the same buyer account and publisher.");
                }

                // recover from deleted deal
                tmpDeal.ObjectState       = ObjectState.Modified;
                tmpDeal.DealName          = deal.DealName;
                tmpDeal.DealTypeId        = deal.DealTypeId;
                tmpDeal.FloorPriceCents   = deal.FloorPriceCents;
                tmpDeal.CeilingPriceCents = deal.CeilingPriceCents;
                tmpDeal.UtcStartDateTime  = deal.UtcStartDateTime;
                tmpDeal.UtcEndDateTime    = deal.UtcEndDateTime;
                tmpDeal.CurrencyId        = deal.CurrencyId;
                deal = tmpDeal;
            }
            else
            {
                deal.ObjectState = ObjectState.Added;
                deal.DealUuid    = IdentityValue.GenerateNewId();
            }

            deal.DealStatusId        = (int)CampaignStatusEnum.Live;
            deal.UtcCreatedDateTime  = _clock.UtcNow;
            deal.UtcModifiedDateTime = null;

            // save
            _dealRepositoryAsync.InsertOrUpdateGraph(deal);
            await _brandscreenContext.SaveChangesAsync();

            return(deal);
        }
Пример #8
0
        public async Task CreateStrategy(AdGroup strategy)
        {
            strategy.AdGroupUuid        = IdentityValue.GenerateNewId();
            strategy.AdGroupStatusId    = (int)CampaignStatusEnum.Pending;
            strategy.UtcCreatedDateTime = _clock.UtcNow;

            strategy.UseBrandscreenVertical   = true;
            strategy.BypassClassificationHide = false;

            strategy.UseLocalTimeBudgeting     = true;
            strategy.UseLocalCurrencyBudgeting = true;

            // goal
            strategy.BudgetPeriodId           = (int)StrategyTypeEnum.OngoingMonthly;
            strategy.GoalTypeId               = (int)(strategy.MediaTypeId == (int)MediaTypeEnum.Dooh ? GoalTypeEnum.Impressions : GoalTypeEnum.Actions);
            strategy.PacingStyleId            = (int)PacingStyleEnum.Evenly;
            strategy.PacingStyleOptionId      = (int)PacingStyleEvenlyModeEnum.Normal;
            strategy.UtcOriginalStartDateTime = _clock.UtcNow;
            strategy.UtcStartDateTime         = _clock.UtcNow;
            strategy.UtcEndDateTime           = null;

            // constraint
            strategy.UniqueConstraintAmount   = 0;
            strategy.UniqueConstraintPeriodId = (int)UniqueConstraintPeriodEnum.PerDay;
            strategy.SpendConstraintPeriodId  = (int)PeriodTypeEnum.PerDay;

            // targetting mode
            strategy.LanguageTargetingMode      = (int)TargetingActionEnum.Targeting;
            strategy.DeviceTargetingMode        = (int)TargetingActionEnum.Targeting;
            strategy.DayPartTargetingMode       = (int)TargetingActionEnum.Targeting;
            strategy.PagePositionTargetingMode  = (int)TargetingActionEnum.Targeting;
            strategy.MobileCarrierTargetingMode = (int)TargetingActionEnum.Targeting;

            strategy.CountryTargetingMode              = (int)TargetingActionEnum.Avoiding;
            strategy.RegionTargetingMode               = (int)TargetingActionEnum.Avoiding;
            strategy.CityTargetingMode                 = (int)TargetingActionEnum.Avoiding;
            strategy.PostcodeTargetingMode             = (int)TargetingActionEnum.Avoiding;
            strategy.DoohGeoLocationGroupTargetingMode = (int)TargetingActionEnum.Avoiding;

            strategy.Vertical1TargetingMode = (int)TargetingActionEnum.Avoiding;
            strategy.Vertical2TargetingMode = (int)TargetingActionEnum.Avoiding;
            strategy.Vertical3TargetingMode = (int)TargetingActionEnum.Avoiding;

            strategy.ExchangeTargetingMode  = (int)TargetingActionEnum.Avoiding;
            strategy.SiteTargetingMode      = (int)TargetingActionEnum.Avoiding;
            strategy.PublisherTargetingMode = (int)TargetingActionEnum.Avoiding;

            // brand safety
            var campaign = await _campaignRepositoryAsync.Queryable()
                           .Include(x => x.BuyerAccount)
                           .Include(x => x.AdvertiserProduct)
                           .FirstAsync(x => x.CampaignId == strategy.CampaignId);

            if (campaign.AdvertiserProduct.BrandSafetyModeId != (int)BrandSafetyModeEnum.PageLevelSafety)
            {
                strategy.PageLevelBrandSafetyLevel = 0d;
            }
            else
            {
                strategy.PageLevelBrandSafetyLevel = Regex.IsMatch(campaign.BuyerAccount.CompanyName, _strategySettings.RegexBrandSafetyBypassingAccounts, RegexOptions.Compiled | RegexOptions.IgnoreCase)
                    ? _strategySettings.BrandSafetyLevelForBypassingAccounts
                    : 100d;
            }

            // optimisation
            strategy.UseBinomialFilter = false; // TODO:

            // save
            _adGroupRepositoryAsync.Insert(strategy);
            await _brandscreenContext.SaveChangesAsync();
        }