public async Task <IActionResult> PutTodoItem(string id, Product product) { if (id != product.Id) { return(BadRequest()); } _ctx.Entry(product).State = EntityState.Modified; try { await _ctx.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ProductExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutUserTiles(Guid id, UserTiles payload) { if (id != payload.Guid) { return(BadRequest()); } var userTile = await _context.UserTiles.FindAsync(id); if (userTile == null) { return(NotFound()); } if (!IsUserAllowed(userTile)) { return(Forbid()); } //Reset the username so the username can't be edited payload.Username = GetUsername(); //Deatach _context.Entry(userTile).State = EntityState.Detached; //Modify _context.Entry(payload).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!UserTilesExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }