// PUT api/Genres/5 public HttpResponseMessage PutGenre(int id, Genre genre) { if (!ModelState.IsValid) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState)); } if (id != genre.Id) { return(Request.CreateResponse(HttpStatusCode.BadRequest)); } db.Entry(genre).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException ex) { return(Request.CreateErrorResponse(HttpStatusCode.NotFound, ex)); } return(Request.CreateResponse(HttpStatusCode.OK, genre)); }
public IHttpActionResult PutMovie(int id, Movie movie) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != movie.MovieId) { return(BadRequest()); } db.Entry(movie).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!MovieExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
// PUT api/ReviewsByGenre/5 public HttpResponseMessage PutvWGetReviewsByGenre(string id, vWGetReviewsByGenre vwgetreviewsbygenre) { if (!ModelState.IsValid) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState)); } if (id != vwgetreviewsbygenre.Name) { return(Request.CreateResponse(HttpStatusCode.BadRequest)); } db.Entry(vwgetreviewsbygenre).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException ex) { return(Request.CreateErrorResponse(HttpStatusCode.NotFound, ex)); } return(Request.CreateResponse(HttpStatusCode.OK)); }
public ActionResult AddMyEmployee(Employee employee) { if (!ModelState.IsValid) { EmployeeManiViewModel model = new EmployeeManiViewModel { Employee = new Employee(), Titles = _db.Titles.ToList() }; return(View(model)); } _db.Entry(employee).State = System.Data.Entity.EntityState.Added; _db.SaveChanges(); return(RedirectToAction("AddMyEmployeeDetail", new { id = employee.EmployeeID })); }
public ActionResult Edit([Bind(Include = "MovieId,Title,Length,Price,Amount,Date,Description,Director,IMDBScore")] Movie movie) { if (ModelState.IsValid) { db.Entry(movie).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("MovieDetails")); } return(View(movie)); }
public ActionResult Edit([Bind(Include = "MovieId,Title,Price,ImageUrl")] Movie movie) { if (ModelState.IsValid) { db.Entry(movie).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(movie)); }
public async Task <ActionResult> Edit([Bind(Include = "MovieId,Title,Length,Price,Amount,Date")] Movie movie) { if (ModelState.IsValid) { db.Entry(movie).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(movie)); }
public ActionResult Edit(Movie movie) { if (ModelState.IsValid) { db.Entry(movie).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.GenreId = new SelectList(db.Genres, "GenreId", "Name", movie.GenreId); ViewBag.ActorId = new SelectList(db.Actors, "ActorId", "Name", movie.ActorId); return(View(movie)); }
public void Delete(T obj) { _db.Entry <T>(obj).State = System.Data.Entity.EntityState.Deleted; }