Ejemplo n.º 1
0
 // Trang tổng quát các nhãn hàng
 public IActionResult ProductBrandsOverview()
 {
     if (IsLogedIn() == true)
     {
         AdminProductBrandsViewModel vm = new AdminProductBrandsViewModel()
         {
             ProductBrand = new ProductBrand()
             {
                 Admin_Id = (int)HttpContext.Session.GetInt32("Admin_Id")
             },
             ProductBrands = _context.ProductBrands.OrderBy(p => p.Name).ToList(),
             Products      = _context.Products.ToList()
         };
         return(View(vm));
     }
     else
     {
         return(RedirectToAction("Login"));
     }
 }
Ejemplo n.º 2
0
 public async Task <IActionResult> SearchProductBarndAdmin(string key_s, int?page)
 {
     if (key_s == null)
     {
         return(Redirect("~/Admin/ProductBrandsOverview"));
     }
     else
     {
         AdminProductBrandsViewModel vm = new AdminProductBrandsViewModel()
         {
             ProductBrand = new ProductBrand()
             {
                 Admin_Id = (int)HttpContext.Session.GetInt32("Admin_Id")
             },
             ProductBrands = _context.ProductBrands.Where(p => p.Name.ToUrlFriendly().Contains(key_s.ToUrlFriendly().Trim())).ToList(),
             Products      = _context.Products.ToList()
         };
         return(View(vm));
     }
 }
Ejemplo n.º 3
0
 public IActionResult ProductBrandsOverview(AdminProductBrandsViewModel vm)
 {
     if (IsLogedIn() == true)
     {
         if (ModelState.IsValid)
         {
             _context.ProductBrands.Add(vm.ProductBrand);
             _context.SaveChanges();
             return(View(
                        new AdminProductBrandsViewModel()
             {
                 ProductBrand = new ProductBrand()
                 {
                     Admin_Id = (int)HttpContext.Session.GetInt32("Admin_Id")
                 },
                 ProductBrands = _context.ProductBrands.OrderBy(p => p.Name).ToList(),
                 Products = _context.Products.ToList()
             }
                        ));
         }
         else
         {
             return(View(
                        new AdminProductBrandsViewModel()
             {
                 ProductBrand = vm.ProductBrand,
                 ProductBrands = _context.ProductBrands.OrderBy(p => p.Name).ToList(),
                 Products = _context.Products.ToList()
             }
                        ));
         }
     }
     else
     {
         return(RedirectToAction("Login"));
     }
 }