Search Results

Search found 1 results on 1 pages for 'user1662380'.

Page 1/1 | 1 

  • ASP.net MVC3 howto edit sql database

    - by user1662380
    MovieStoreEntities MovieDb = new MovieStoreEntities(); public ActionResult Edit(int id) { //var EditMovie1 = MovieDb AddMovieModel EditMovie = (from M in MovieDb.Movies from C in MovieDb.Categories where M.CategoryId == C.Id where M.Id == id select new AddMovieModel { Name = M.Name, Director = M.Director, Country = M.Country, categorie = C.CategoryName, Category = M.CategoryId }).FirstOrDefault(); //AddMovieModel EditMovie1 = MovieDb.Movies.Where(m => m.Id == id).Select(m => new AddMovieModel {m.Id }).First(); List<CategoryModel> categories = MovieDb.Categories .Select(category => new CategoryModel { Category = category.CategoryName, id = category.Id }) .ToList(); ViewBag.Category = new SelectList(categories, "Id", "Category"); return View(EditMovie); } // // POST: /Default1/Edit/5 [HttpPost] public ActionResult Edit(AddMovieModel Model2) { List<CategoryModel> categories = MovieDb.Categories .Select(category => new CategoryModel { Category = category.CategoryName, id = category.Id }) .ToList(); ViewBag.Category = new SelectList(categories, "Id", "Category"); if (ModelState.IsValid) { //MovieStoreEntities model = new MovieStoreEntities(); MovieDb.SaveChanges(); return View("Thanks2", Model2); } else return View(); } This is the Code that I have wrote to edit Movie details and update database in the sql server. This dont have any compile errors, But It didnt update sql server database.

    Read the article

1