Esempio n. 1
0
        public ActionResult DeleteConfirmed(int id)
        {
            MetalStore metalStore = db.MetalStores.Find(id);

            db.MetalStores.Remove(metalStore);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Esempio n. 2
0
        public ActionResult Partial(MetalStore metalStore)
        {
            var metalStores = db.MetalStores.Include(m => m.MetalName).Include(m => m.MetalType).Include(m => m.Unit).Include(m => m.Unit1).Include(m => m.Unit2);

            // return View();
            //ViewBag.Message = "Это частичное представление.";
            return(PartialView(metalStores.ToList()));
        }
Esempio n. 3
0
        // GET: MetalStores/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            MetalStore metalStore = db.MetalStores.Find(id);

            if (metalStore == null)
            {
                return(HttpNotFound());
            }
            return(View(metalStore));
        }
Esempio n. 4
0
 public ActionResult Edit([Bind(Include = "id,Photo,MetType,MetName,Size1,Size2,Size3,SizeUnits,Quantity,QuantityUnits,Cost,CostUnits,OtherInfo,InUse")] MetalStore metalStore)
 {
     if (ModelState.IsValid)
     {
         db.Entry(metalStore).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.MetName       = new SelectList(db.MetalNames, "id", "MetalName1", metalStore.MetName);
     ViewBag.MetType       = new SelectList(db.MetalTypes, "id", "MetTypeName", metalStore.MetType);
     ViewBag.CostUnits     = new SelectList(db.Units, "id", "UnitName", metalStore.CostUnits);
     ViewBag.QuantityUnits = new SelectList(db.Units, "id", "UnitName", metalStore.QuantityUnits);
     ViewBag.SizeUnits     = new SelectList(db.Units, "id", "UnitName", metalStore.SizeUnits);
     return(View(metalStore));
 }
Esempio n. 5
0
        // GET: MetalStores/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            MetalStore metalStore = db.MetalStores.Find(id);

            if (metalStore == null)
            {
                return(HttpNotFound());
            }
            ViewBag.MetName       = new SelectList(db.MetalNames, "id", "MetalName1", metalStore.MetName);
            ViewBag.MetType       = new SelectList(db.MetalTypes, "id", "MetTypeName", metalStore.MetType);
            ViewBag.CostUnits     = new SelectList(db.Units, "id", "UnitName", metalStore.CostUnits);
            ViewBag.QuantityUnits = new SelectList(db.Units, "id", "UnitName", metalStore.QuantityUnits);
            ViewBag.SizeUnits     = new SelectList(db.Units, "id", "UnitName", metalStore.SizeUnits);
            return(View(metalStore));
        }
Esempio n. 6
0
        public ActionResult AddPicture(MetalStore metalStore, HttpPostedFileBase uploadImage)
        {
            if (ModelState.IsValid && uploadImage != null)
            {
                byte[] imageData = null;
                // считываем переданный файл в массив байтов
                using (var binaryReader = new BinaryReader(uploadImage.InputStream))
                {
                    imageData = binaryReader.ReadBytes(uploadImage.ContentLength);
                }
                // установка массива байтов
                metalStore.Photo = imageData;

                db.MetalStores.Add(metalStore);
                db.SaveChanges();

                return(RedirectToAction("Index"));
            }
            return(View(metalStore));
        }