示例#1
0
        public IActionResult Delete(int Id, [FromServices] DBDeiba dB)
        {
            Product product = dB.Find <Product>(Id);

            dB.Remove(product);
            dB.SaveChanges();
            return(RedirectToAction("Lstproduct", "Panel"));
        }
示例#2
0
        public IActionResult Update(int Id, [FromServices] DBDeiba dB)
        {
            Product product = dB.Find <Product>(Id);

            ViewData["Barands"] = dB.Barands.ToList();
            ViewData["P"]       = product;

            return(View(product));
        }
示例#3
0
        public IActionResult Updateconfirm(ProductViewModel model, [FromServices] DBDeiba dB)
        {
            var Product = dB.Find <Product>(model.Id);

            Product.Name     = model.Name;
            Product.Mod      = model.Mod;
            Product.Price    = model.Price;
            Product.Title    = model.Title;
            Product.Barandid = model.Barandid;
            if (model.Img != null)
            {
                byte[] b = new  byte[model.Img.Length];
                model.Img.OpenReadStream().Read(b, 0, b.Length);
                Product.Img = b;
            }
            ;
            dB.Update(Product);
            dB.SaveChanges();

            return(RedirectToAction("Lstproduct", "Panel"));
        }