Пример #1
0
        public ActionResult DeleteConfirmed(string id)
        {
            ProductionCountry productionCountry = db.ProductionCountries.Find(id);

            db.ProductionCountries.Remove(productionCountry);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Пример #2
0
        //----------------------------------------------------------------//

        public static ProductionCountry MapCoutry(ProductionCountryDto countyDto)
        {
            ProductionCountry country = new ProductionCountry()
            {
                Name       = countyDto.name,
                iso_3166_1 = countyDto.iso_3166_1,
            };

            return(country);
        }
Пример #3
0
 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));
 }
Пример #4
0
        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));
        }
Пример #5
0
        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);
                }
            }
        }
Пример #6
0
        // 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));
        }