public async Task <IActionResult> PutCountry(int id, Country country) { if (id != country.CountryId) { return(BadRequest()); } _context.Entry(country).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CountryExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutTeam(int id, Team team) { if (id != team.TeamId) { return(BadRequest()); } _context.Entry(team).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TeamExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutInvoiceItems(int id, InvoiceItems invoiceItems) { if (id != invoiceItems.Id) { return(BadRequest()); } db.Entry(invoiceItems).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!InvoiceItemsExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutEmployee(int id, Employee employee) { if (id != employee.Id) { return(BadRequest()); } _context.Entry(employee).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!EmployeeExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public IHttpActionResult PutProduct(long id, Product product) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != product.Id) { return(BadRequest()); } db.Entry(product).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!ProductExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public async Task <IActionResult> PutProduct(int id, Product product) { if (id != product.Id) { return(BadRequest()); } _context.Entry(product).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ProductExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public IActionResult DeleteBook(long id, IFormCollection form) { Book book = context.Set <Book>().SingleOrDefault(c => c.Id == id); context.Entry(book).State = Microsoft.EntityFrameworkCore.EntityState.Deleted; context.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "ID,FirstName,LastName,EmploymentDate")] MasterRoaster masterRoaster) { if (ModelState.IsValid) { db.Entry(masterRoaster).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(masterRoaster)); }
public void Update(TEntity item) { _context.Entry(item).State = EntityState.Modified; _context.SaveChanges(); }
public ActionResult Edit(Coffee coffee) { db.Entry(coffee).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult EditFilm(CoffeeContext coffee) { db.Entry(coffee).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); }