// POST: Movies/Edit/5 // To protect from overposting attacks, please enable the specific properties you want to bind to, for // more details see https://go.microsoft.com/fwlink/?LinkId=317598. //[HttpPost] //[ValidateAntiForgeryToken] //public ActionResult Edit([Bind(Include = "ID,Title,WeekendRevenure,GrossRevenue,Released,Recommended")] Movie movie) //{ // if (ModelState.IsValid) // { // db.Entry(movie).State = EntityState.Modified; // db.SaveChanges(); // return RedirectToAction("Index"); // } // return View(movie); //} // GET: Movies/Delete/5 //public ActionResult Delete(int? id) //{ // if (id == null) // { // return new HttpStatusCodeResult(HttpStatusCode.BadRequest); // } // Movie movie = db.Movies.Find(id); // if (movie == null) // { // return HttpNotFound(); // } // return View(movie); //} // POST: Movies/Delete/5 //[HttpPost, ActionName("Delete")] //[ValidateAntiForgeryToken] //public ActionResult DeleteConfirmed(int id) //{ // Movie movie = db.Movies.Find(id); // db.Movies.Remove(movie); // db.SaveChanges(); // return RedirectToAction("Index"); //} protected override void Dispose(bool disposing) { if (disposing) { repository.Dispose(); } base.Dispose(disposing); }
protected override void Dispose(bool disposing) { _movie.Dispose(); }
static void Main(string[] args) { using (MyDatabase db = new MyDatabase()) { MovieRepository movieRepo = new MovieRepository(); var lista = movieRepo.GetAll().Where(x => x.Title.Contains("e")); foreach (var movie in lista) { Console.WriteLine(movie.Title); foreach (var actor in movie.Actors) // de douleuei { Console.WriteLine(actor.FirstName); } } Console.WriteLine("wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww"); var lista2 = movieRepo.GetAll().Where(x => x.Title.Contains("a")); foreach (var movie in lista2) { Console.WriteLine(movie.Title); foreach (var actor in movie.Actors) { Console.WriteLine(actor.FirstName); } } movieRepo.Dispose(); //AUTO gia ton allo tropo Sta Services!!!!!!!!!!1 chack it out //giati mporo na anoigokeliso to service opote opote opote goustarw //ALLA an eisai LAzy Loading sthn GetAll PREPEI na kanw include(x=>x. ... ) tou les fere kai auto ActorRepository actorRepository = new ActorRepository(); foreach (var item in actorRepository.GetAll()) // de douleuei { Console.WriteLine(item.FirstName); } actorRepository.Dispose(); //var movies = db.Movies; //san I quirable interfase // tha steilei SQL QUERY STI BASI //zitao ka8e fora apo toservar na mou stelnei thn katallili pliroforia // de me endiaferei gia ena sugkekrimeno query sti basi kai exo para polu RAM //foreach (var movie in movies) //{ // Console.WriteLine("{0,-6}{0,-15}", movie.MovieId, movie.Title); //} //var movies = db.Movies.ToList(); //simbato me IEnumerable //tha stalei query sti basi poy 8a sou ferei ol aosa xxreiazomai sato run time ////tha to xrismopoiiso gia polla//tha ferei osa xreiazomai sto run time ////fere mou AUTOO apo ti basi, stoxeuMENA!!!!! me linq //Console.WriteLine("===================================="); //Goldennn.Services.MovieRepository movieRepository = new MovieRepository(); //var movies1 = movieRepository.GetAll().Where(x => x.Title.Contains("e")); ////auti ti stigmi i linq psaxnei sto run, momeory (oxi ston sql server, auto einai allos dromos). //foreach (var movie in movies1) //{ // Console.WriteLine("{0,-6}{0,-15}", movie.MovieId, movie.Title); //} ////App.PrintMoviess(); //Console.WriteLine("psakse tainia"); //string choice = Console.ReadLine(); //int id; //if (Int32.TryParse(choice, out id)) //{ // App.PrintById(2); //} //else //{ // App.PrintById(null); //} ////app.PrintMovies() //Movie m = new Movie() { MovieId = 10, Title = "Battleship Potemkin" }; //movieRepository.Insert(m); //App.PrintMovies(); // kai ektipono gt exo ftiaksei auton ton mixanismo //Console.WriteLine("================================================="); //movieRepository.Insert(m); //App.PrintMovies(); ////app.PrintMovies() //Movie m1 = new Movie() { MovieId = 10, Title = "Amelie" }; //movieRepository.Update(m); //App.PrintMovies(); // kai ektipono gt exo ftiaksei auton ton mixanismo //Console.WriteLine("================================================="); //movieRepository.Insert(m); //App.PrintMovies(); ////app.PrintMovies() //Movie m3 = new Movie() { Title = "Lion Kings" }; //var movie3 = movieRepository.GetById(10); //if (!(movie3 is null)) //{ // movie3.Title = m3.Title; //} //movieRepository.Update(movie3); //App.PrintById(10); //App.PrintMovies(); //Console.WriteLine("========================================="); } Console.ReadKey(); }