public async Task <IActionResult> PutOrder(int id, Order order) { if (id != order.Id) { 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> PutBicicleta(int id, Bicicleta bicicleta) { if (id != bicicleta.Id) { return(BadRequest()); } _context.Entry(bicicleta).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!BicicletaExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public IHttpActionResult PutPaymentDetail(int id, PaymentDetail paymentDetail) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != paymentDetail.PMId) { return(BadRequest()); } db.Entry(paymentDetail).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!PaymentDetailExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public async Task <IActionResult> PutNews(int id, News news) { if (id != news.Id) { return(BadRequest()); } var updateNews = _context.News.Find(id); updateNews.Text = news.Text; updateNews.Title = news.Title; _context.Entry(updateNews).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!NewsExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public IHttpActionResult PutUser(long id, User user) { if (id != user.Id) { return(BadRequest()); } db.Entry(user).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!UserExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public async Task <IHttpActionResult> PutItem(int id, Item item) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != item.Id) { return(BadRequest()); } db.Entry(item).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ItemExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public async Task <IActionResult> PutDivision(int id, Division division) { Division d = await _context.Division.FindAsync(id); if (d == null | division.Name == null) { return(BadRequest()); } d.Name = division.Name; _context.Entry(d).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DivisionExists(id)) { return(NotFound()); } else { throw; } } return(new OkObjectResult(d)); }
public async Task <IActionResult> PutPaymentMethod(int id, PaymentMethod paymentMethod) { if (id != paymentMethod.Id) { return(BadRequest()); } _context.Entry(paymentMethod).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PaymentMethodExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutShoppingList(int id, ShoppingList shoppingList) { if (id != shoppingList.ID) { return(BadRequest()); } _context.Entry(shoppingList).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ShoppingListExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public IHttpActionResult PutHotDog(int id, HotDog hotdog) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != hotdog.HotDogId) { return(BadRequest()); } db.Entry(hotdog).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!HotDogExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public async Task <IActionResult> PutThanhPho(int id, ThanhPho thanhPho) { if (id != thanhPho.MaTp) { return(BadRequest()); } _context.Entry(thanhPho).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ThanhPhoExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutQuanHuyen(int id, QuanHuyen quanHuyen) { if (id != quanHuyen.MaQuanHuyen) { return(BadRequest()); } _context.Entry(quanHuyen).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!QuanHuyenExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutLoan(int id, Loan loan) { if (id != loan.LoanId) { return(NotFound()); } _context.Entry(loan).State = EntityState.Modified; try { _loanRepository.Update(loan); var save = await _loanRepository.SaveAsync(loan); } catch (DbUpdateConcurrencyException) { if (!LoanExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutPeople(int id, People people) { if (id != people.PeopleID) { return(BadRequest()); } _context.Entry(people).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PeopleExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutXaPhuong(int id, XaPhuong xaPhuong) { if (id != xaPhuong.MaXaPhuong) { return(BadRequest()); } _context.Entry(xaPhuong).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!XaPhuongExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public IHttpActionResult PutRole(int id, Role role) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != role.id) { return(BadRequest()); } db.Entry(role).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!RoleExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public async Task <IActionResult> PutGallery(Guid id, Gallery gallery) { if (id != gallery.Id) { return(BadRequest()); } _context.Entry(gallery).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!GalleryExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutAgreement(int id, Agreement agreement) { if (id != agreement.Id) { return(BadRequest()); } _context.Entry(agreement).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AgreementExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutClasse(int id, Classe classe) { if (id != classe.IdClasse) { return(BadRequest()); } _context.Entry(classe).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ClasseExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutProcedureModel(int id, ProcedureModel procedureModel) { if (id != procedureModel.ProcedureId) { return(BadRequest()); } _context.Entry(procedureModel).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ProcedureModelExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutBrand([FromBody] Brand brand) { if (brand.Id < 0) { return(BadRequest()); } try { _context.Entry(brand).State = EntityState.Modified; await _context.SaveChangesAsync(); return(Ok()); } catch (DbUpdateConcurrencyException) { if (!BrandExists(brand.Id)) { return(NotFound()); } else { throw; } } }
public IHttpActionResult PutPrato(string id, Prato prato) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != prato.PNome) { return(BadRequest()); } db.Entry(prato).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!PratoExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public async Task <IActionResult> PatchStuff(int id, Stuff stuff) { Stuff r = await _context.Stuff.FindAsync(id); if (r == null) { return(BadRequest()); } if (stuff.LastName != null) { r.LastName = stuff.LastName; } if (stuff.FirstName != null) { r.FirstName = stuff.FirstName; } if (stuff.DivisionId != 0) { r.DivisionId = stuff.DivisionId; } _context.Entry(r).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!StuffExists(id)) { return(NotFound()); } else { throw; } } return(new OkObjectResult(r)); }
public IHttpActionResult ToggleFeature(long id) { Feature feature = db.Features.Find(id); if (feature == null) { return(NotFound()); } //Create the subclass Feature featureModel = CreateFeature(feature, false); //Toggles accordingly the subclass permissions featureModel.Toggle(); db.Entry(feature).State = EntityState.Detached; db.Entry(featureModel).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!FeatureExists(id)) { return(NotFound()); } else { throw; } } return(Ok()); }
public void Update(long id, T obj) { context.Entry(obj).State = EntityState.Modified; Save(); }