public ActionResult DeleteConfirmed(string id) { ProductionCountry productionCountry = db.ProductionCountries.Find(id); db.ProductionCountries.Remove(productionCountry); db.SaveChanges(); return(RedirectToAction("Index")); }
//----------------------------------------------------------------// public static ProductionCountry MapCoutry(ProductionCountryDto countyDto) { ProductionCountry country = new ProductionCountry() { Name = countyDto.name, iso_3166_1 = countyDto.iso_3166_1, }; return(country); }
public ActionResult Edit([Bind(Include = "iso_3166_1,name")] ProductionCountry productionCountry) { if (ModelState.IsValid) { db.Entry(productionCountry).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(productionCountry)); }
public ActionResult Create([Bind(Include = "iso_3166_1,name")] ProductionCountry productionCountry) { if (ModelState.IsValid) { db.ProductionCountries.Add(productionCountry); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(productionCountry)); }
private static void HandleCountries(JMoviesEntities entities, Production production, Production savedProduction) { Movie movie = production as Movie; Movie savedMovie = savedProduction as Movie; if (movie != null && movie.Countries != null) { foreach (ProductionCountry productionCountry in movie.Countries.ToArray()) { EntityEntry entry = null; EntityEntry countryEntry = null; Country savedCountry = entities.Country.FirstOrDefault(e => e.Identifier == productionCountry.Country.Identifier); if (savedCountry != null) { productionCountry.Country.ID = savedCountry.ID; countryEntry = CommonDBHelper.MarkEntityAsUpdated(entities, productionCountry.Country); } else { productionCountry.Country.ID = CommonDBHelper.GetNewID <Country>(entities, e => e.ID); countryEntry = entities.Country.Add(productionCountry.Country); } entities.SaveChanges(); productionCountry.ProductionID = productionCountry.Production.ID; productionCountry.Production = null; productionCountry.CountryID = productionCountry.Country.ID; productionCountry.Country = null; ProductionCountry savedProductionCountry = null; if (savedMovie != null) { savedProductionCountry = entities.ProductionCountry.FirstOrDefault(e => e.ProductionID == savedMovie.ID && e.CountryID == productionCountry.CountryID); } if (savedProductionCountry != null) { productionCountry.ID = savedProductionCountry.ID; entry = CommonDBHelper.MarkEntityAsUpdated(entities, productionCountry); } else { CommonDBHelper.DetachAllEntries(entities); productionCountry.ID = CommonDBHelper.GetNewID <ProductionCountry>(entities, e => e.ID); entry = entities.ProductionCountry.Add(productionCountry); } entities.SaveChanges(); CommonDBHelper.DetachAllEntries(entities); } } }
// GET: ProductionCountries/Delete/5 public ActionResult Delete(string id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ProductionCountry productionCountry = db.ProductionCountries.Find(id); if (productionCountry == null) { return(HttpNotFound()); } return(View(productionCountry)); }