예제 #1
0
        public async Task AddAsync(BonusCashInDto bonusCashIn)
        {
            using (var context = _contextFactory.CreateDataContext())
            {
                var historyEntity = TransactionHistoryEntity.Create(bonusCashIn);
                var bonusEntity   = BonusCashInEntity.Create(bonusCashIn);

                var campaign = await context.Campaigns.FindAsync(bonusCashIn.CampaignId);

                if (campaign != null && campaign.CampaignName != bonusCashIn.CampaignName)
                {
                    campaign.CampaignName = bonusCashIn.CampaignName;
                }

                if (campaign == null)
                {
                    campaign = CampaignEntity.Create(bonusCashIn.CampaignId, bonusCashIn.CampaignName);
                }

                bonusEntity.Campaign = campaign;

                context.BonusCashIns.Add(bonusEntity);
                context.TransactionHistories.Add(historyEntity);

                await context.SaveChangesAsync();
            }
        }
예제 #2
0
        public async Task AddAsync(FeeCollectedOperationDto operation)
        {
            using (var context = _contextFactory.CreateDataContext())
            {
                var entity = FeeCollectedOperationEntity.Create(operation);

                var historyEntity = TransactionHistoryEntity.Create(operation);

                context.FeeCollectedOperations.Add(entity);

                context.TransactionHistories.Add(historyEntity);

                await context.SaveChangesAsync();
            }
        }