public async Task <object> Post([FromBody] TaxItemViewModel model) { var taxItem = Mapper.Map <TaxItem>(model); _context.TaxItems.AddOrUpdate(taxItem); await _context.SaveChangesAsync(); Mapper.Map(taxItem, model); return(Ok(model)); }
public async Task <object> Put([FromBody] TaxItemViewModel model) { var tax = await _context.TaxItems.FindAsync(model.Id); if (tax == null) { return(BadRequest()); } var taxItem = Mapper.Map <TaxItem>(model); _context.TaxItems.AddOrUpdate(taxItem); await _context.SaveChangesAsync(); Mapper.Map(taxItem, model); return(Ok(model)); }