public async Task <ActionResult <BoozeItem> > PostBoozeItem(BoozeItem boozeItem) { string idstring = boozeItem.Source + boozeItem.ProductNumber.ToString(); string idhash = HelperFunctions.ComputeSha256Hash(idstring); boozeItem.id = idhash; _context.BoozeItems.Add(boozeItem); await _context.SaveChangesAsync(); return(CreatedAtAction("GetBoozeItem", new { id = idhash }, boozeItem)); }
public async Task <IActionResult> PutBoozeItem(string id, BoozeItem boozeItem) { _context.Entry(boozeItem).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!BoozeItemExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }