Beispiel #1
0
        public IActionResult Fileconfirm(FileViewModel model, [FromServices] DBDeiba dB)
        {
            File file = new File
            {
                Name = model.Name
            };

            if (model.Listlaptop != null)
            {
                byte[] b = new byte[model.Listlaptop.Length];
                model.Listlaptop.OpenReadStream().Read(b, 0, b.Length);
                file.Listlaptop = b;
            }

            if (model.Listmobile != null)
            {
                byte[] a = new byte[model.Listmobile.Length];
                model.Listmobile.OpenReadStream().Read(a, 0, a.Length);
                file.Listmobile = a;
            }
            dB.Add(file);
            dB.SaveChanges();

            return(RedirectToAction("Fileinsert", "Panel"));
        }
Beispiel #2
0
        public IActionResult Productconfirm(ProductViewModel model, [FromServices] DBDeiba dB)
        {
            Product a = new Product
            {
                Name     = model.Name,
                Price    = model.Price,
                Title    = model.Title,
                Barandid = model.Barandid
            };

            if (model.Img != null)
            {
                if (model.Img.Length < 5 * Math.Pow(1024, 2))
                {
                    byte[] b = new byte [model.Img.Length];
                    model.Img.OpenReadStream().Read(b, 0, b.Length);

                    a.Img = b;
                }
            }

            dB.Add(a);
            dB.SaveChanges();

            return(RedirectToAction("PanelManager", "Panel"));
        }
Beispiel #3
0
        public IActionResult Delete(int Id, [FromServices] DBDeiba dB)
        {
            Product product = dB.Find <Product>(Id);

            dB.Remove(product);
            dB.SaveChanges();
            return(RedirectToAction("Lstproduct", "Panel"));
        }
Beispiel #4
0
        public IActionResult Barandconfirm(BarandViewModel model, [FromServices] DBDeiba dB)
        {
            Barand b = new Barand
            {
                Name = model.Name
            };

            dB.Add(b);
            dB.SaveChanges();
            return(RedirectToAction("InsertBarand", "Panel"));
        }
Beispiel #5
0
        public IActionResult Postconfirm(PostViewModel model, [FromServices] DBDeiba dB)
        {
            Post post = new Post {
                Name  = model.Name,
                Title = model.Title
            };

            dB.Add(post);
            dB.SaveChanges();

            return(RedirectToAction("Postinsert", "Post"));
        }
Beispiel #6
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"));
        }