public void Add(Movie movie) { using (var ctx = new ShopContextConnection()) { ctx.Movies.Attach(movie); ctx.Movies.Add(movie); ctx.SaveChanges(); } }
public ActionResult Delete(Movie movie) { facade.GetMovieRepository().Delete(movie); if (movie == null) { return HttpNotFound(); } return RedirectToAction("Index", "Movie"); }
public void Delete(Movie movie) { using (var ctx = new ShopContextConnection()) { ctx.Movies.Attach(movie); //var thisMovie = ctx.Movies.Where(x => x.Id == movie.Id).FirstOrDefault(); ctx.Movies.Remove(movie); ctx.SaveChanges(); } }
public void orderLine_properties_set_test() { OrderLine line = new OrderLine(); var movie = new Movie() { Id = 1, Title = "Smurf" }; line.Movie = movie; line.Amount = 10; Assert.AreEqual(line.Movie, movie, "My movie blabla"); Assert.AreEqual(line.Amount, 10, "babla"); }
//public void Edit([Bind(Include = "Id,Title,Year,Price")] Movie movie) //{ // if (ModelState.IsValid) // { // ctx.Entry(movie).State = EntityState.Modified; // ctx.SaveChanges(); // return RedirectToAction("Index"); // } //} public void Edit(Movie movie) { using (var ctx = new ShopContextConnection()) { //A gift to Lars from KBTZ team. Enjoy! var movieDB = ctx.Movies.FirstOrDefault(x => x.Id == movie.Id); movieDB.Genre = ctx.Genres.FirstOrDefault(x => x.Id == movie.Genre.Id); movieDB.Title = movie.Title; movieDB.Price = movie.Price; movieDB.Year = movie.Year; movieDB.Description = movie.Description; movieDB.url = movie.url; movieDB.MovieCoverUrl = movie.MovieCoverUrl; ctx.SaveChanges(); //ctx.SaveChanges(); } }
public ActionResult Create(Movie movie, HttpPostedFileBase file) { facade.GetMovieRepository().Add(movie); return Redirect("Index"); }
static void Main(string[] args) { Movie movie = new Movie() { Id = 2, Price = 200d, Title = "Lego movie 2", Year = DateTime.Now.AddYears(-1) }; Facade facade = new Facade(); facade.GetMovieRepository().Add(movie); }