public async Task <IActionResult> PutOrder(string id, Order order) { if (id != order.Orderid) { return(BadRequest()); } _context.Entry(order).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!OrderExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutProduct(string id, Product product) { if (id != product.Productid) { return(BadRequest()); } _context.Entry(product).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ProductExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> ChangeRoleOfAccount([FromRoute] string id, [FromForm] Account account) { var username = account.Username; var role = account.Role; var _account = AccountInfor(username); if (id != username) { return(BadRequest()); } if (_account.Role == role || role == "" || role == null || role != "Admin" || role != "Customer" || role != "Mod") { return(BadRequest()); } _account.Role = role; _context.Entry(_account).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AccountExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }