コード例 #1
0
        public ActionResult Create([Bind(Include = "Product_TypeID,Name")] Product_Type product_Type)
        {
            if (ModelState.IsValid)
            {
                db.Product_Type.Add(product_Type);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(product_Type));
        }
コード例 #2
0
        public ActionResult Create([Bind(Include = "CountryID,Name")] Country country)
        {
            if (ModelState.IsValid)
            {
                db.Country.Add(country);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(country));
        }
コード例 #3
0
ファイル: FuelsController.cs プロジェクト: casezma/BBMIS
        public ActionResult Create([Bind(Include = "FuelID,Name")] Fuel fuel)
        {
            if (ModelState.IsValid)
            {
                db.Fuel.Add(fuel);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(fuel));
        }
コード例 #4
0
ファイル: MotorsController.cs プロジェクト: casezma/BBMIS
        public ActionResult Create([Bind(Include = "MotorID,Name")] Motor motor)
        {
            if (ModelState.IsValid)
            {
                db.Motor.Add(motor);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(motor));
        }
コード例 #5
0
        public ActionResult Create([Bind(Include = "StateID,Name,CountryID")] State state)
        {
            if (ModelState.IsValid)
            {
                db.State.Add(state);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.CountryID = new SelectList(db.Country, "CountryID", "Name", state.CountryID);
            return(View(state));
        }
コード例 #6
0
        public ActionResult Create([Bind(Include = "CityID,Name,StateID")] City city)
        {
            if (ModelState.IsValid)
            {
                db.City.Add(city);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.StateID = new SelectList(db.State, "StateID", "Name", city.StateID);
            return(View(city));
        }
コード例 #7
0
        public ActionResult Create([Bind(Include = "SupplierID,Name,Description,Address,Lat,Long,CityID")] Supplier supplier)
        {
            if (ModelState.IsValid)
            {
                db.Supplier.Add(supplier);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.CityID = new SelectList(db.City, "CityID", "Name", supplier.CityID);
            return(View(supplier));
        }
コード例 #8
0
ファイル: ProductsController.cs プロジェクト: casezma/BBMIS
        public ActionResult Create([Bind(Include = "ProductID,Description,Price,Product_TypeID")] Product product)
        {
            if (ModelState.IsValid)
            {
                db.Product.Add(product);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.Product_TypeID = new SelectList(db.Product_Type, "Product_TypeID", "Name", product.Product_TypeID);
            return(View(product));
        }
コード例 #9
0
        public ActionResult Create([Bind(Include = "DerivationID,Description,MotorID,FuelID,Mnemonic_Bodystyle")] Derivation derivation)
        {
            if (ModelState.IsValid)
            {
                db.Derivation.Add(derivation);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.Mnemonic_Bodystyle = new SelectList(db.CarBuild, "Mnemonic_Bodystyle", "Mnemonic_Vehicle", derivation.Mnemonic_Bodystyle);
            ViewBag.FuelID             = new SelectList(db.Fuel, "FuelID", "Name", derivation.FuelID);
            ViewBag.MotorID            = new SelectList(db.Motor, "MotorID", "Name", derivation.MotorID);
            return(View(derivation));
        }
コード例 #10
0
ファイル: CarBuildIO.cs プロジェクト: casezma/BBMIS
        public void ImportarCarBuild(BBMISContext context)
        {
            using (var reader = new StreamReader("CarBuildVolumes.csv"))
                using (var csv = new CsvReader(reader))
                {
                    var records = new List <CarBuildVolumes>();
                    csv.Read();
                    csv.ReadHeader();


                    while (csv.Read())
                    {
                        var record = new CarBuildVolumes
                        {
                            CarBuildVolumesID = csv.GetField <string>("CarBuildVolumesID"),
                            CarBuildID        = csv.GetField("Mnemonic_Vehicle"),
                            Year   = csv.GetField <int>("Year"),
                            Volume = csv.GetField <float>("Volume")
                        };
                        records.Add(record);
                    }


                    context.Database.ExecuteSqlCommand("DELETE FROM [dbo].[CarBuildVolumes]");

                    context.CarBuildVolumes.AddRange(records);
                    context.SaveChanges();
                }
        }