public async Task <IActionResult> PutShopAccount(string id, ShopAccount shopAccount) { if (id != shopAccount.Username) { return(BadRequest()); } _context.Entry(shopAccount).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ShopAccountExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <ActionResult <ShopAccount> > PostShopAccount(ShopAccount shopAccount) { _context.ShopAccount.Add(shopAccount); try { await _context.SaveChangesAsync(); } catch (DbUpdateException) { if (ShopAccountExists(shopAccount.Username)) { return(Conflict()); } else { throw; } } return(CreatedAtAction("GetShopAccount", new { id = shopAccount.Username }, shopAccount)); }