コード例 #1
0
        public ActionResult Create(ManufacturerProductViewModel manufacturerProductVM)
        {
            using (GoodSupplyEntities db = new GoodSupplyEntities())
            {
                var manufacturerProducts = new ManufacturerProducts
                {
                    Name            = manufacturerProductVM.ManufacturerProducts.Name,
                    CatalogNumber   = manufacturerProductVM.ManufacturerProducts.CatalogNumber,
                    ImageUrl        = manufacturerProductVM.ManufacturerProducts.ImageUrl,
                    PackageQuantity = manufacturerProductVM.ManufacturerProducts.PackageQuantity,
                    Width           = manufacturerProductVM.ManufacturerProducts.Width,
                    Length          = manufacturerProductVM.ManufacturerProducts.Length,
                    Height          = manufacturerProductVM.ManufacturerProducts.Height,
                    Manufacturers   = manufacturerProductVM.ManufacturerProducts.Manufacturers,
                    ManufacturerId  = manufacturerProductVM.ManufacturerProducts.ManufacturerId,
                    Products        = manufacturerProductVM.ManufacturerProducts.Products,
                    ProductId       = manufacturerProductVM.ManufacturerProducts.ProductId
                };

                if (ModelState.IsValid)
                {
                    db.ManufacturerProducts.Add(manufacturerProducts);
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
                manufacturerProductVM.Manufacturers = db.Manufacturers.ToList();
                manufacturerProductVM.Products      = db.Products.ToList();
                return(View(manufacturerProductVM));
            }
        }
コード例 #2
0
        // GET: Details
        public ActionResult Details(int?id)
        {
            using (GoodSupplyEntities db = new GoodSupplyEntities())
            {
                if (id == null)
                {
                    return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
                }

                ManufacturerProducts manufacturerProducts = db.ManufacturerProducts.Find(id);

                if (manufacturerProducts == null)
                {
                    return(HttpNotFound());
                }

                var model = new ManufacturerProductViewModel
                {
                    ManufacturerProducts = manufacturerProducts,
                    Manufacturers        = db.Manufacturers.ToList(),
                    Products             = db.Products.ToList()
                };
                return(View(model));
            }
        }
コード例 #3
0
 // GET: Create
 public ActionResult Create()
 {
     using (GoodSupplyEntities db = new GoodSupplyEntities())
     {
         var manufacturers = db.Manufacturers.ToList();
         var products      = db.Products.ToList();
         var model         = new ManufacturerProductViewModel
         {
             Manufacturers = manufacturers,
             Products      = products
         };
         return(View(model));
     }
 }