public async Task <Channel> CreateAsync(Channel channel) { var entity = _mapper.ToEntity(channel); await _context.Channels.AddAsync(entity); await _context.SaveChangesAsync(); return(_mapper.ToDomain(entity)); }
public async Task <Advertisement> CreateAsync(AdvertisementEntry advertisementEntry) { var entity = _mapper.ToEntity(advertisementEntry); await _context.Advertisements.AddAsync(entity); await _context.SaveChangesAsync(); return(_mapper.ToDomain(entity)); }
public async Task <AdvertisingBase> AddAdvertisingAsync(AdvertisingBase advertisingRequest) { var advertising = _mapper.Map <Advertising>(advertisingRequest); advertising.CreatedDate = DateTime.Now; advertising.UpdatedDate = advertising.CreatedDate; _db.Advertisings.Add(advertising); await _db.SaveChangesAsync(); return(_mapper.Map <AdvertisingBase>(advertising)); }
public async Task <ChannelBase> AddChannelAsync(ChannelBase request) { var channel = _mapper.Map <Channel>(request); channel.CreatedDate = DateTime.Now; channel.UpdatedDate = channel.CreatedDate; _db.Channels.Add(channel); await _db.SaveChangesAsync(); return(_mapper.Map <ChannelBase>(channel)); }
public async Task UpsertAsync(Bid bid) { var existBid = await GetByIdAsync(bid.Id); if (existBid == null) { await _marketingDbContext.Bids.AddAsync(bid); } else { existBid.Name = bid.Name; existBid.RecordDate = bid.RecordDate; } await _marketingDbContext.SaveChangesAsync(); }
public async Task AddBasketChangeEvent(BasketChangeEvent basketChangeEvent) { await using (var marketingDbContext = new MarketingDbContext(dbContextOptions)) { await marketingDbContext.BasketChangeEvents.AddAsync(basketChangeEvent); await marketingDbContext.SaveChangesAsync(); } }
private async void InitializeAsync() { var isThereBanks = await _marketingDbContext.Banks.AnyAsync(); if (isThereBanks) { return; } for (int i = 100000001; i <= 100002000; i++) { var app = new Bank { Bic = i.ToString(), Name = $"Банк {i - 100000000}", RecordDate = DateTime.Now }; await _marketingDbContext.AddAsync(app); } await _marketingDbContext.SaveChangesAsync(); }
public async Task <PublishingBase> PublishAdAsync(PublishingBase request) { var publishing = _mapper.Map <Publishing>(request); publishing.CreatedDate = DateTime.Now; _db.Publishings.Add(publishing); await _db.SaveChangesAsync(); return(_mapper.Map <PublishingBase>(publishing)); }
private async void InitializeAsync() { var isThereApps = await _marketingDbContext.Applications.AnyAsync(); if (isThereApps) { return; } for (var i = 1; i <= 1000; i++) { var app = new Application { Code = $"AP-{i}", Name = $"Приложение {i}", RecordDate = DateTime.Now }; await _marketingDbContext.AddAsync(app); } await _marketingDbContext.SaveChangesAsync(); }