public void Save(StockDto dto)
 {
     if (dto.IsNew)
     {
         Stock stock = dto.MapTo <Stock>();
         this._repository.Insert(stock);
     }
     else
     {
         Stock stock = this._repository.Get(dto.Id);
         dto.MapTo(stock);
     }
 }
Example #2
0
 public async Task UpdateAsync(StockDto stock)
 {
     _context.Entry(stock.MapTo <Stock>()).State = EntityState.Modified;
     await _context.SaveChangesAsync();
 }
Example #3
0
        public async Task CreateAsync(StockDto stock)
        {
            await _context.AddAsync(stock.MapTo <Stock>());

            await _context.SaveChangesAsync();
        }