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); } }
public async Task UpdateAsync(StockDto stock) { _context.Entry(stock.MapTo <Stock>()).State = EntityState.Modified; await _context.SaveChangesAsync(); }
public async Task CreateAsync(StockDto stock) { await _context.AddAsync(stock.MapTo <Stock>()); await _context.SaveChangesAsync(); }