public ActionResult EditMovie(int id) { moviesall mvall = new moviesall(); Movy movie = mvall.Movies.Single(x => x.Id == id); return(View(movie)); }
public ActionResult EditMovie(Movy model) { //MoviesDTO dto = new MoviesDTO(); Movy dto = new Movy(); using (moviesall db = new moviesall()) { // ViewBag.Category = new SelectList(db.Category, "Id", "Name"); if (db.Movies.Count(x => x.Name == model.Name) > 1) { ModelState.AddModelError("", "The title already taken"); return(View(model)); } string yr = model.Year.ToString(); if (string.IsNullOrWhiteSpace(model.Name) || string.IsNullOrWhiteSpace(model.Language) || string.IsNullOrWhiteSpace(model.Category) || string.IsNullOrWhiteSpace(model.Genre) || string.IsNullOrWhiteSpace(yr)) { ModelState.AddModelError("", "All fields required"); return(View(model)); } moviesall mvall = new moviesall(); // mvall.Movies(model) = EntityState.Modified; db.Entry(model).State = EntityState.Modified; db.SaveChanges(); //temp data TempData["SM"] = "Movie Edited!"; } return(RedirectToAction("Index")); }
public ActionResult Home(string SearchBy, string Search) { moviesall db = new moviesall(); if (SearchBy == "Name") { return(View(db.Movies.Where(x => x.Name.StartsWith(Search) || Search == null).ToList())); } else if (SearchBy == "Category") { return(View(db.Movies.Where(x => x.Category == Search || Search == null).ToList())); } else if (SearchBy == "Language") { return(View(db.Movies.Where(x => x.Genre == Search || Search == null).ToList())); } else { TempData["SM"] = "ALL"; return(View(db.Movies.ToList())); } }/// <summary>