コード例 #1
0
ファイル: pagesController.cs プロジェクト: 010203abbas/Deiba
        public IActionResult Janebi([FromServices] DBDeiba dB)
        {
            IQueryable <Product> product = dB.Products;

            ViewData["tst"] = product.Where(p => p.Barandid == 11).ToList();
            return(View());
        }
コード例 #2
0
ファイル: PanelController.cs プロジェクト: 010203abbas/Deiba
        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"));
        }
コード例 #3
0
ファイル: PanelController.cs プロジェクト: 010203abbas/Deiba
        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"));
        }
コード例 #4
0
ファイル: PostController.cs プロジェクト: 010203abbas/Deiba
        public IActionResult Postinsert([FromServices] DBDeiba dB)
        {
            Post post = new Post();

            ViewData["P"] = dB.Posts.ToList();
            return(View());
        }
コード例 #5
0
ファイル: PanelController.cs プロジェクト: 010203abbas/Deiba
        public IActionResult PanelManager([FromServices] DBDeiba dB)
        {
            ViewData["Barands"] = dB.Barands.ToList();



            return(View());
        }
コード例 #6
0
ファイル: PanelController.cs プロジェクト: 010203abbas/Deiba
        public IActionResult Delete(int Id, [FromServices] DBDeiba dB)
        {
            Product product = dB.Find <Product>(Id);

            dB.Remove(product);
            dB.SaveChanges();
            return(RedirectToAction("Lstproduct", "Panel"));
        }
コード例 #7
0
ファイル: PanelController.cs プロジェクト: 010203abbas/Deiba
        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));
        }
コード例 #8
0
ファイル: PanelController.cs プロジェクト: 010203abbas/Deiba
        public IActionResult Barandconfirm(BarandViewModel model, [FromServices] DBDeiba dB)
        {
            Barand b = new Barand
            {
                Name = model.Name
            };

            dB.Add(b);
            dB.SaveChanges();
            return(RedirectToAction("InsertBarand", "Panel"));
        }
コード例 #9
0
        public IActionResult Index([FromServices] DBDeiba dB, int Pageid = 1)
        {
            int skip = (Pageid - 1) * 3;

            ViewData["tst"] = dB.Products.OrderBy(p => p.Id).Skip(skip).Take(3).ToList();
            int Count = dB.Products.Count();

            ViewBag.PageId    = Pageid;
            ViewBag.Pagecount = Count / 3;

            return(View());
        }
コード例 #10
0
ファイル: PostController.cs プロジェクト: 010203abbas/Deiba
        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"));
        }
コード例 #11
0
ファイル: PanelController.cs プロジェクト: 010203abbas/Deiba
        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"));
        }
コード例 #12
0
ファイル: PanelController.cs プロジェクト: 010203abbas/Deiba
 public IActionResult Lstproduct([FromServices] DBDeiba dB)
 {
     ViewData["lst"] = dB.Products.ToList();
     return(View());
 }
コード例 #13
0
ファイル: PanelController.cs プロジェクト: 010203abbas/Deiba
 public IActionResult Fileshow([FromServices] DBDeiba dB)
 {
     return(View(dB.Files.ToList()));
 }