Ejemplo n.º 1
0
        /// <inheritdoc />
        public async Task <long> CreateAsync(PromotionCampaignCreationData data)
        {
            if (data == null)
            {
                throw new ArgumentNullException(nameof(data));
            }

            var entity = data.ToEntity();

            await ModixContext.PromotionCampaigns.AddAsync(entity);

            await ModixContext.SaveChangesAsync();

            entity.CreateAction.CampaignId = entity.Id;
            await ModixContext.SaveChangesAsync();

            await RaisePromotionActionCreatedAsync(entity.CreateAction);

            return(entity.Id);
        }
        /// <inheritdoc />
        public async Task <PromotionActionSummary> CreateAsync(PromotionCampaignCreationData data)
        {
            if (data == null)
            {
                throw new ArgumentNullException(nameof(data));
            }

            var entity = data.ToEntity();

            await ModixContext.PromotionCampaigns.AddAsync(entity);

            await ModixContext.SaveChangesAsync();

            entity.CreateAction.CampaignId = entity.Id;
            await ModixContext.SaveChangesAsync();

            var action = await ModixContext.PromotionActions.AsNoTracking()
                         .Where(x => x.Id == entity.CreateActionId)
                         .AsExpandable()
                         .Select(PromotionActionSummary.FromEntityProjection)
                         .FirstAsync();

            return(action);
        }