Exemple #1
0
 public Task CreateAdvertiser(Advertiser advertiser)
 {
     advertiser.AdvertiserUuid     = IdentityValue.GenerateNewId();
     advertiser.UtcCreatedDateTime = _clock.UtcNow;
     _advertiserRepositoryAsync.Insert(advertiser);
     return(_brandscreenContext.SaveChangesAsync());
 }
Exemple #2
0
        /// <summary>
        /// get save commands
        /// </summary>
        /// <returns></returns>
        ICommand GetSaveObjectCommand()
        {
            if (IdentityValue.IsNullOrEmpty())
            {
                return(null);
            }
            var dataPackage = WarehouseManager.GetDataPackage <ET>(IdentityValue);

            if (dataPackage == null || (!ActivationOption.ForceExecute && dataPackage.Operate != WarehouseDataOperate.Save))
            {
                return(null);
            }
            var dalService = ContainerManager.Resolve <DAI>();

            if (dataPackage.LifeSource == DataLifeSource.New) //new add value
            {
                return(dalService.Add(dataPackage.WarehouseData));
            }
            else if (dataPackage.HasValueChanged) // update value
            {
                var data = dataPackage.WarehouseData;
                return(dalService.Modify(data, dataPackage.PersistentData));
            }
            return(null);
        }
Exemple #3
0
 public Task CreateCampaign(Campaign campaign)
 {
     campaign.CampaignUuid       = IdentityValue.GenerateNewId();
     campaign.UtcCreatedDateTime = _clock.UtcNow;
     _compaignAsyncRepository.Insert(campaign);
     return(_brandscreenContext.SaveChangesAsync());
 }
Exemple #4
0
        public bool Delete(IdentityValue identity)
        {
            var entity = _db.Transaction.FirstOrDefault(f => f.TransactionId == identity.ToInt);

            if (entity == null)
            {
                throw new ApplicationException("Registro no encontrado");
            }

            var itemLocation = _db.ItemLocation.FirstOrDefault(f =>
                                                               f.ItemId == entity.ItemId &&
                                                               f.LocationId == entity.LocationId
                                                               );

            if (itemLocation != null && entity.TransactionTypeId != ETransactionType.UnusableReturn)
            {
                itemLocation.Quantity -= entity.Quantity;

                if (itemLocation.Quantity == 0)
                {
                    _db.Entry(itemLocation).State = EntityState.Deleted;
                }
            }

            _db.Entry(entity).State = EntityState.Deleted;

            return(_db.SaveChanges() > 0);
        }
 public Task CreateBrand(AdvertiserProduct brand)
 {
     brand.AdvertiserProductUuid = IdentityValue.GenerateNewId();
     brand.UtcCreatedDateTime    = _clock.UtcNow;
     _advertiserProductRepositoryAsync.Insert(brand);
     return(_brandscreenContext.SaveChangesAsync());
 }
 public Task CreateSegment(Segment segment)
 {
     segment.RtbSegmentId       = IdentityValue.GenerateNewId();
     segment.SegmentStatusId    = (int)CampaignStatusEnum.Pending;
     segment.UtcCreatedDateTime = _clock.UtcNow;
     _segmentRepositoryAsync.Insert(segment);
     return(_brandscreenContext.SaveChangesAsync());
 }
Exemple #7
0
        public bool Delete(IdentityValue identity)
        {
            var entity = _db.Manufacturer.FirstOrDefault(f => f.ManufacturerId == identity.ToInt);

            if (entity == null)
            {
                throw new ApplicationException("Registro no encontrado");
            }

            _db.Entry(entity).State = EntityState.Deleted;

            return(_db.SaveChanges() > 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();
            }
        }
Exemple #9
0
        /// <summary>
        /// Serves as a hash function for a <see cref="T:CSF.Entities.Entity{TIdentity}"/> object.
        /// </summary>
        /// <returns>
        /// A hash code for this instance that is suitable for use in hashing algorithms and data structures such as a
        /// hash table.
        /// </returns>
        public override int GetHashCode()
        {
            if (!_cachedHashCode.HasValue)
            {
                if (HasIdentity)
                {
                    _cachedHashCode = IdentityValue.GetHashCode();
                }
                else
                {
                    _cachedHashCode = base.GetHashCode();
                }
            }

            return(_cachedHashCode.Value);
        }
Exemple #10
0
        /// <summary>
        /// geet remove command
        /// </summary>
        /// <returns></returns>
        ICommand GetRemoveObjectCommand()
        {
            if (IdentityValue.IsNullOrEmpty())
            {
                return(null);
            }
            var dataPackage = WarehouseManager.GetDataPackage <ET>(IdentityValue);

            if (dataPackage == null || (!ActivationOption.ForceExecute && (dataPackage.Operate != WarehouseDataOperate.Remove || dataPackage.IsRealRemove)))
            {
                return(null);
            }
            var dalService = ContainerManager.Resolve <DAI>();
            var data       = dataPackage.WarehouseData;

            return(dalService.Delete(data));
        }
 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();
 }
Exemple #12
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);
        }
Exemple #13
0
 public Item Requery(IdentityValue identity)
 {
     return(Find(f => f.ItemId == identity.ToInt));
 }
Exemple #14
0
 public Location Requery(IdentityValue identity)
 {
     return(Find(f => f.LocationId == identity.ToInt));
 }
Exemple #15
0
        /// <summary>
        /// Returns a <see cref="System.String"/> that represents the current <see cref="T:CSF.Entities.Entity{TIdentity}"/>.
        /// </summary>
        /// <returns>
        /// A <see cref="System.String"/> that represents the current <see cref="T:CSF.Entities.Entity{TIdentity}"/>.
        /// </returns>
        public override string ToString()
        {
            string identityPart = HasIdentity? IdentityValue.ToString() : Resources.Strings.NoIdentity;

            return(String.Format(Resources.Strings.IdentityFormat, this.GetType().Name, identityPart));
        }
Exemple #16
0
 /// <summary>
 /// Get hash code
 /// </summary>
 /// <returns>Return model hash code</returns>
 public sealed override int GetHashCode()
 {
     return(IdentityValue.GetHashCode());
 }
        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();
        }
Exemple #18
0
 public Manufacturer Requery(IdentityValue identity)
 {
     return(Find(f => f.ManufacturerId == identity.ToInt));
 }
Exemple #19
0
 public Area Requery(IdentityValue identity)
 {
     return(Find(f => f.AreaId == identity.ToInt));
 }
Exemple #20
0
 public Transaction Requery(IdentityValue identity)
 {
     return(Find(f => f.TransactionId == identity.ToInt));
 }