//public IEnumerable<Movie> GetByDSpecification(Expression<Func<Movie, bool>> predicate) //{ // // _ds.GetBySpec(m => m.Id == 1); // //using (var db = new MovieDataContext()) // //{ // return _dc.Movies.Where(predicate).ToList(); // //} //} public Movie Update(Movie updatedMovie) { var entry = _dc.Entry(updatedMovie); entry.State = EntityState.Modified; _dc.SaveChanges(); return updatedMovie; }
public static MvcHtmlString Image(this HtmlHelper helper, Movie movie) { var tagBuilder = new TagBuilder("img"); tagBuilder.MergeAttribute("src", "http://fontmeme.com/images/Star-Wars-Poster.jpg"); tagBuilder.MergeAttribute("alt", movie.Title); var html = tagBuilder.ToString(TagRenderMode.SelfClosing); return MvcHtmlString.Create(html); }
public ActionResult Create(Movie newMovie) { if (ModelState.IsValid) { var dataSource = new MovieDataSource(); dataSource.Add(newMovie); return RedirectToAction("Details", new {id = newMovie.Id}); } return View(newMovie); }
public IHttpActionResult PostMovie(Movie newMovie) { if (ModelState.IsValid) { var db = new MovieDataSource(); db.Add(newMovie); return CreatedAtRoute("DefaultApi", new { id = newMovie.Id }, newMovie); } return BadRequest(ModelState); }
public ActionResult Edit(Movie updatedMovie) { if (ModelState.IsValid) { var dataSource = new MovieDataSource(); var model = dataSource.Update(updatedMovie); return RedirectToAction("Details", new {id = model.Id}); } return View(updatedMovie); }
public void Add(Movie newMovie) { _dc.Movies.Add(newMovie); _dc.SaveChanges(); }