Exemplo n.º 1
0
 // GET: Home
 public ActionResult Index(ListProductViewModel listProductViewModel)
 {
     listProductViewModel.ListProduct = DatabaseProduct.Lay_DS_SanPham();
     return(View(listProductViewModel));
     //CCallApi.GetTemplateAsync(CConfig.ListProduct + "?tensp=aaaa");
     //return View();
 }
Exemplo n.º 2
0
 public ActionResult ProductDetail(string FriendlyUrl, string string1, string string2)
 {
     try
     {
         Classification Objcata = cms_db.GetObjClasscifiByFriendlyUrl(FriendlyUrl);
         if (Objcata != null)
         {
             this.SetInforMeta(Objcata.ClassificationMetakeyword, Objcata.ClassificationMetaDes);
             ListProductViewModel model = new ListProductViewModel();
             model.CataObj    = Objcata;
             model.lstProduct = cms_db.GetlstProductByCataId(Objcata.ClassificationId);
             return(View("ListPartial", model));
         }
         else
         {
             DetailProductViewModel model = new DetailProductViewModel();
             model.MainProduct    = cms_db.GetObjProductByFriendlyURL(FriendlyUrl);
             model.CataObj        = cms_db.GetObjClasscifiById(model.MainProduct.CategoryId.Value);
             model.lstSameProduct = cms_db.GetlstProductByCataIdHasNum(model.MainProduct.CategoryId.Value, 8);
             model.lstImage       = cms_db.GetLstMediaContent(model.MainProduct.ProductId, (int)EnumCore.ObjTypeId.san_pham).ToList();
             this.SetInforMeta(model.MainProduct.MetadataKeyword, model.MainProduct.MetadataDesc);
             return(View("DetailPartial", model));
         }
     }
     catch (Exception e)
     {
         cms_db.AddToExceptionLog("ProductDetail", "ProductController(Public)", e.ToString());
         return(RedirectToAction("ErrorExeption", "ErrorMessage"));
     }
 }
Exemplo n.º 3
0
 public ActionResult AllProduct()
 {
     try
     {
         this.SetInforMeta("", "");
         List <ListProductViewModel> _tmpmodel = new List <ListProductViewModel>();
         List <Classification>       lstCata   = cms_db.GetlstClassifiBySchemeId((int)EnumCore.ClassificationScheme.san_pham).ToList();
         List <Classification>       lstCata2  = new List <Classification>();
         foreach (Classification _val in lstCata)
         {
             List <Classification> tmpcate = cms_db.GetlstClassifiByParentId(_val.ClassificationId).ToList();
             if (tmpcate.Count == 0)
             {
                 lstCata2.Add(_val);
             }
         }
         foreach (Classification _val in lstCata2)
         {
             ListProductViewModel tmp = new ListProductViewModel();
             if (_val.ObjPrent != null)
             {
                 tmp.ParentCataObj = _val.ObjPrent;
             }
             tmp.CataObj    = _val;
             tmp.lstProduct = cms_db.GetlstProductByCataIdHasNum(_val.ClassificationId, 3);
             _tmpmodel.Add(tmp);
         }
         return(View("ListAll", _tmpmodel));
     }
     catch (Exception e)
     {
         cms_db.AddToExceptionLog("AllProduct", "ProductController(Public)", e.ToString());
         return(RedirectToAction("ErrorExeption", "ErrorMessage"));
     }
 }
Exemplo n.º 4
0
        public ActionResult Index()
        {
            List <ProductItemViemModel> list = new List <ProductItemViemModel>();
            var temp = _context.Products.ToList();

            foreach (var item in temp)
            {
                ProductItemViemModel product = new ProductItemViemModel
                {
                    Count       = item.Count,
                    Id          = item.Id,
                    IsAvailable = item.IsAvailable,
                    Name        = item.Name,
                    Price       = item.Price
                };
                list.Add(product);
            }
            temp.Clear();
            ListProductViewModel model = new ListProductViewModel()
            {
                listProduct = list
            };

            return(View(model));
        }
Exemplo n.º 5
0
        public async Task <ResultViewModel> Show([FromRoute] string product_id)
        {
            bool productIdIsValid = Guid.TryParse(product_id, out Guid output);

            if (!productIdIsValid)
            {
                return new ResultViewModel()
                       {
                           Success = false,
                           Message = "ID inválido."
                       }
            }
            ;

            var product = await _productRepository.Find(product_id);

            ListProductViewModel data = product == null
        ? null
        : new ListProductViewModel(product);

            return(new ResultViewModel()
            {
                Success = true,
                Message = null,
                Data = data
            });
        }
Exemplo n.º 6
0
        public ActionResult ListProduct(Int32?Page, String InvoiceDescription, Int32?FamilyId, Int32?SubFamilyId, Int32?FatherId)
        {
            var model = new ListProductViewModel();

            model.Fill(CargarDatosContext(), Page, InvoiceDescription, FamilyId, SubFamilyId, FatherId);
            return(View(model));
        }
Exemplo n.º 7
0
        public IActionResult Index(int?pageSize, string drop, int page = 1)
        {
            var products = new ListProductViewModel();

            if (pageSize == null)
            {
                pageSize = _configuration.GetValue <int>("PageSize");
            }
            products.PageSize = pageSize;
            products.SortType = drop;
            products.Data     = _productRepository.GetAllPaging(null, "", page, pageSize.Value);
            if (drop == "hightolow")
            {
                products.Data.Results = products.Data.Results.OrderByDescending(x => x.Price).ToList();
            }
            if (drop == "lowtohigh")
            {
                products.Data.Results = products.Data.Results.OrderByDescending(x => x.Price).Reverse().ToList();
            }
            if (drop == "atoz")
            {
                products.Data.Results = products.Data.Results.OrderByDescending(x => x.Name).Reverse().ToList();
            }
            if (drop == "ztoa")
            {
                products.Data.Results = products.Data.Results.OrderByDescending(x => x.Name).ToList();
            }
            return(View(products));
        }
        // GET: Product
        public async Task <IActionResult> Index()
        {
            ListProductViewModel viewModel = new ListProductViewModel();

            viewModel.Product = await _context.Producten.Include(p => p.ProductType).ToListAsync();

            viewModel.Frisdrankenlijst = viewModel.Product.Where(x => x.ProductType.Naam == "Frisdrank").ToList();
            viewModel.Alcohollijst     = viewModel.Product.Where(x => x.ProductType.Naam == "Alcohol").ToList();
            viewModel.Snacklijst       = viewModel.Product.Where(x => x.ProductType.Naam == "Snack").ToList();

            foreach (var item in viewModel.Frisdrankenlijst)
            {
                item.Aantal = 0;
            }
            foreach (var item in viewModel.Alcohollijst)
            {
                item.Aantal = 0;
            }
            foreach (var item in viewModel.Snacklijst)
            {
                item.Aantal = 0;
            }
            viewModel.Bestelling = new Bestelling()
            {
                Productenlijst = new List <Product> {
                }
            };
            return(View(viewModel));
        }
Exemplo n.º 9
0
        public ActionResult ListMyProducts()
        {
            List <Product> products;

            if (HttpContext.Cache["listProducts"] == null)
            {
                using (NorthwindEntities db = new NorthwindEntities())
                {
                    products = db.Products.Include("Category").Include("Supplier").ToList();
                }

                HttpContext.Cache.Add("listProducts", products, null, Cache.NoAbsoluteExpiration, TimeSpan.FromMinutes(20), CacheItemPriority.Normal, null);
            }
            else
            {
                products = HttpContext.Cache["listProducts"] as List <Product>;
            }

            ListProductViewModel model = new ListProductViewModel
            {
                Products = products
            };

            return(View(model));
        }
 /// <summary>
 /// GET: Product
 /// </summary>
 /// <param name="listProductViewModel"></param>
 /// <returns></returns>
 public ActionResult Index(ListProductViewModel listProductViewModel)
 {
     listProductViewModel.Categories = businessManager.GetAllCategorie();
     listProductViewModel.Products   = businessManager.GetAllProduit();
     listProductViewModel.Search     = "";
     return(View(listProductViewModel));
 }
Exemplo n.º 11
0
        public async System.Threading.Tasks.Task <ActionResult> ListProduct()
        {
            var vm = new ListProductViewModel();
            await vm.Fill(CargarDatosContext());

            return(View(vm));
        }
Exemplo n.º 12
0
        public IActionResult ListProducts()
        {
            ListProductViewModel ListProductsView = new ListProductViewModel();
            Product product1 = new Product()
            {
                Nombre = "Raqueta",
                Precio = 320000,
                Color  = "Blanca"
            };
            Product product2 = new Product()
            {
                Nombre = "Balon Futbol",
                Precio = 100000,
                Color  = "W/B"
            };
            Product product3 = new Product()
            {
                Nombre = "Tennis",
                Precio = 200000,
                Color  = "Azules"
            };

            ListProductsView.Products.Add(product1);
            ListProductsView.Products.Add(product2);
            ListProductsView.Products.Add(product3);
            return(View(ListProductsView));
        }
        public async Task <IActionResult> VerminderenMetEen(ListProductViewModel viewModel, int Product_ID)
        {
            viewModel.ProductEventChange = _context.Producten.Include(x => x.ProductType).FirstOrDefault(x => x.ProductID == Product_ID);
            viewModel.ProductEventChange.Aantal_in_Frigo -= 1;
            if (viewModel.ProductEventChange.Aantal_in_Frigo > 0)
            {
                try
                {
                    _context.Update(viewModel.ProductEventChange);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ProductExists(viewModel.ProductEventChange.ProductID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
            }
            viewModel.DrankInMagazijn = await _context.Producten.Include(p => p.ProductType).ToListAsync();

            viewModel.DrankInIjskast = new List <Product>();
            foreach (Product item in viewModel.DrankInMagazijn)
            {
                if (!viewModel.DrankInIjskast.Contains(item) && item.Aantal_in_Frigo >= 0)
                {
                    viewModel.DrankInIjskast.Add(item);
                }
            }
            return(View(nameof(IndexManager), viewModel));
        }
Exemplo n.º 14
0
        public ActionResult ListProduct(Int32?p)
        {
            var vm = new ListProductViewModel();

            vm.Fill(CargarDatosContext(), p);
            return(View(vm));
        }
Exemplo n.º 15
0
        public IActionResult Search(ListProductViewModel viewModel)
        {
            if (!string.IsNullOrWhiteSpace(viewModel.ProductSearch))
            {
                viewModel.Products = _unitOfWork.Products.Find(p => p.Name.Contains(viewModel.ProductSearch)).ToList();
                return(View("Index", viewModel));
            }

            return(RedirectToAction("Index"));
        }
        public ActionResult Index(int?page)
        {
            AppDbContext         dbContext   = new AppDbContext();
            ListProductViewModel listProduct = new ListProductViewModel();

            listProduct.Brands = dbContext.getBrands.ToList();

            List <ProductModels>       products    = dbContext.getProducts.ToList();
            List <GetProductViewModel> getProducts = new List <GetProductViewModel>();

            /*Get products details*/
            foreach (var item in products)
            {
                ModelModels    model    = dbContext.getModels.SingleOrDefault(m => m.Id == item.ModelId);
                BrandModels    brand    = dbContext.getBrands.SingleOrDefault(b => b.BrandId == model.BrandId);
                CategoryModels category = dbContext.getCategories.SingleOrDefault(c => c.CategoryId == model.CategoryId);

                GetProductViewModel getProduct = new GetProductViewModel
                {
                    Id          = item.Id,
                    Name        = model.Name,
                    Brand       = brand.Brand,
                    Category    = category.Category,
                    Price       = item.Price,
                    Color       = item.Color,
                    Storage     = item.Storage,
                    Processor   = item.Processor,
                    Memory      = item.Memory,
                    Display     = item.Display,
                    Details     = item.Details,
                    CreatedBy   = item.CreatedBy,
                    CreatedDate = item.CreatedDate
                };
                getProduct.Photos = dbContext.getProductPhotos(item.Id).ToList();

                getProducts.Add(getProduct);
            }

            /*Search product and sort by date*/
            listProduct.Products = getProducts.OrderByDescending(p => p.CreatedDate).ToList().ToPagedList(page ?? 1, 20);


            /*Get the number of each product in a brand*/
            listProduct.EachProductsOfBrands = new List <int>();
            foreach (var brand in listProduct.Brands)
            {
                List <ProductModels> productsOfBrands = dbContext.getProductBrands(brand.BrandId).ToList();

                int numberOfBrand = productsOfBrands.Count;
                listProduct.EachProductsOfBrands.Add(numberOfBrand);
            }

            /*Create Index view with product details*/
            return(View(listProduct));
        }
        public async Task <IActionResult> PlusEenSnack(ListProductViewModel viewModel, int Product_ID)
        {
            viewModel.GekozenSnack         = _context.Producten.Include(x => x.ProductType).Where(x => x.ProductType.Naam == "Snack").FirstOrDefault(x => x.ProductID == Product_ID);
            viewModel.GekozenSnack.Aantal += 1;
            viewModel.Snacklijst           = await _context.Producten.Include(p => p.ProductType).Where(x => x.ProductType.Naam == "Snack").ToListAsync();

            viewModel.Alcohollijst = await _context.Producten.Include(p => p.ProductType).Where(x => x.ProductType.Naam == "Alcohol").ToListAsync();

            viewModel.Frisdrankenlijst = await _context.Producten.Include(p => p.ProductType).Where(x => x.ProductType.Naam == "Frisdrank").ToListAsync();

            return(View(nameof(Index), viewModel));
        }
 public async Task <IActionResult> Search(ListProductViewModel viewModel)
 {
     if (!string.IsNullOrEmpty(viewModel.ZoekProduct))
     {
         viewModel.Product = await _context.Producten.Include(p => p.ProductType)
                             .Where(x => x.Naam.Contains(viewModel.ZoekProduct)).ToListAsync();
     }
     else
     {
         viewModel.Product = await _context.Producten.Include(p => p.ProductType).ToListAsync();
     }
     return(View("IndexManager", viewModel));
 }
Exemplo n.º 19
0
        public IActionResult Gop(int id, int?pageSize, string sortBy, int page = 1)
        {
            var gop = new ListProductViewModel();

            if (pageSize == null)
            {
                pageSize = _configuration.GetValue <int>("PageSize");
            }
            gop.PageSize = pageSize;
            gop.SortType = sortBy;
            gop.Data     = _productRepository.GetAllByGop(7, page, pageSize.Value);
            return(View(gop));
        }
Exemplo n.º 20
0
 public ActionResult FindProduct(ListProductViewModel viewModel)
 {
     try
     {
         viewModel.ListProducts           = DatabaseInternal.GetListProduct(new ListProductViewModel());
         viewModel.CurrentListProductType = DatabaseInternal.GetListProduct(viewModel);
         //CCallApi.GetTemplateAsync(CConfig.ListProduct+ "?Tensp=aaaa");
     }
     catch (Exception ex)
     {
         LogFile.Error(ex.ToString());   // Ghi thông tin ra file
     }
     return(View(viewModel));
 }
        public ActionResult Search(ListProductViewModel listProductViewModel)
        {
            listProductViewModel.Categories = businessManager.GetAllCategorie();
            Boolean searchForm = listProductViewModel.Search != null;

            if (!searchForm)
            {
                listProductViewModel.Products = getAllProducts();
            }
            else if (searchForm)
            {
                listProductViewModel.Products = businessManager.GetProductsByNameSearch(listProductViewModel.Search);
            }

            return(View("Index", listProductViewModel));
        }
        public async Task <IActionResult> IndexManager()
        {
            ListProductViewModel viewModel = new ListProductViewModel();

            viewModel.DrankInMagazijn = await _context.Producten.Include(p => p.ProductType).ToListAsync();

            viewModel.DrankInIjskast = new List <Product>();
            foreach (Product item in viewModel.DrankInMagazijn)
            {
                if (!viewModel.DrankInIjskast.Contains(item) && item.Aantal_in_Frigo >= 0)
                {
                    viewModel.DrankInIjskast.Add(item);
                }
            }

            return(View(viewModel));
        }
Exemplo n.º 23
0
        public ViewResult Index()
        {
            var products = _productRepo.AllProducts.OrderByDescending(p => p.DateAdded).ToList();

            foreach (var p in products)
            {
                p.Images = _productRepo.GetImages(p.Id).ToList();
            }

            var model = new ListProductViewModel
            {
                Products   = products,
                Categories = _categoryRepo.Categories,
                Statuses   = _statusRepo.Statuses
            };

            return(View(model));
        }
Exemplo n.º 24
0
        public IActionResult List(int?storeID)
        {
            var Products = (storeID.HasValue) ?
                           Db.Products.Where(p => p.StoreID == storeID).ToList() : Db.Products.ToList();

            var productview = new ListProductViewModel()
            {
                Products = Products,
                StoreID  = storeID
            };

            if (Products.Count() == 0)
            {
                return(View("Empty", productview));
            }

            return(View(productview));
        }
Exemplo n.º 25
0
        public List <ListProductViewModel> ListProduct()
        {
            var viewModels = new List <ListProductViewModel>();

            foreach (var product in _context.Products)
            {
                var viewModel = new ListProductViewModel();

                viewModel.Id          = product.Id;
                viewModel.ProductName = product.ProductName;
                viewModel.Description = product.Description;
                viewModel.Price       = product.Price;
                viewModel.Image       = product.Image;

                viewModels.Add(viewModel);
            }

            return(viewModels);
        }
        public async Task DrankenOverzichtExcel()
        {
            ListProductViewModel viewModel = new ListProductViewModel();

            viewModel.Product = await _context.Producten.Include(x => x.ProductType).ToListAsync();

            ExcelPackage.LicenseContext = LicenseContext.NonCommercial;
            ExcelPackage   Ep    = new ExcelPackage();
            ExcelWorksheet Sheet = Ep.Workbook.Worksheets.Add("ExcelProduct");

            Sheet.Cells["A1"].Value = "Naam";
            Sheet.Cells["B1"].Value = "ProductType";
            Sheet.Cells["C1"].Value = "Aankoopprijs";
            Sheet.Cells["D1"].Value = "Verkoopprijs";
            Sheet.Cells["E1"].Value = "Slotwaarde";
            Sheet.Cells["F1"].Value = "Aantal in stock";
            Sheet.Cells["G1"].Value = "Aantal in ijskast";

            int row = 2;

            foreach (var item in viewModel.Product)
            {
                Sheet.Cells[string.Format("A{0}", row)].Value = item.Naam;
                Sheet.Cells[string.Format("B{0}", row)].Value = item.ProductType;
                Sheet.Cells[string.Format("C{0}", row)].Value = item.AankoopPrijs;
                Sheet.Cells[string.Format("C{0}", row)].Style.Numberformat.Format = "0.00";
                Sheet.Cells[string.Format("D{0}", row)].Value = item.VerkoopPrijs;
                Sheet.Cells[string.Format("D{0}", row)].Style.Numberformat.Format = "0.00";
                Sheet.Cells[string.Format("E{0}", row)].Value = item.Slotwaarde;
                Sheet.Cells[string.Format("F{0}", row)].Value = item.Aantal_in_stock;
                Sheet.Cells[string.Format("G{0}", row)].Value = item.Aantal_in_Frigo;
                row++;
            }

            Sheet.Cells["A:AZ"].AutoFitColumns();
            Response.Clear();
            Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
            Response.Headers.Add("content-disposition", "attachment: filename=" + "Report.xlsx");
            await Response.Body.WriteAsync(Ep.GetAsByteArray());

            Response.StatusCode = StatusCodes.Status200OK;
        }
Exemplo n.º 27
0
 public ActionResult ProductList(string FriendlyUrl)
 {
     try
     {
         Classification Objcata = cms_db.GetObjClasscifiByFriendlyUrl(FriendlyUrl);
         if (Objcata != null)
         {
             this.SetInforMeta(Objcata.ClassificationMetakeyword, Objcata.ClassificationMetaDes);
             ListProductViewModel model = new ListProductViewModel();
             model.CataObj = Objcata;
             if (cms_db.GetlstClassifiByParentId(Objcata.ClassificationId).Count() > 0)
             {
                 List <ListProductViewModel> _tmpmodel = new List <ListProductViewModel>();
                 List <Classification>       lstCata   = cms_db.GetlstClassifiByParentId(Objcata.ClassificationId).ToList();
                 foreach (Classification _val in lstCata)
                 {
                     ListProductViewModel tmp = new ListProductViewModel();
                     tmp.CataObj      = _val;
                     tmp.lstProduct   = cms_db.GetlstProductByCataIdHasNum(_val.ClassificationId, 4);
                     ViewBag.MainCata = Objcata;
                     _tmpmodel.Add(tmp);
                 }
                 return(View("ListCatalogryPro", _tmpmodel));
             }
             else
             {
                 model.lstProduct = cms_db.GetlstProductByCataId(Objcata.ClassificationId);
             }
             return(View("ListPartial", model));
         }
         else
         {
             return(RedirectToAction("Index", "Home"));
         }
     }
     catch (Exception e)
     {
         cms_db.AddToExceptionLog("ProductList", "ProductController(Public)", e.ToString());
         return(RedirectToAction("ErrorExeption", "ErrorMessage"));
     }
 }
Exemplo n.º 28
0
        public ActionResult List(int page = 1, string search = "", int marca = 0)
        {
            var pageLen = 12;
            var model   = new ListProductViewModel();
            var from    = (page - 1) * pageLen;

            var listini = _db.listinimarche
                          .Where(i => i.datainiziovalidità == null || i.datainiziovalidità <= DateTime.Today)
                          .Where(i => i.datafinevalidità >= DateTime.Today)
                          .Where(i => i.inuso == "Si")
                          .Where(i => i.idaziendamaster == Const.IdAziendaMaster);

            var results = new List <Product>();

            foreach (var listino in listini)
            {
                var resultList = _db.Database.SqlQuery <Product>(GetProductQuery(listino.idlistino)).ToList();
                if (marca != 0)
                {
                    resultList = resultList.Where(i => i.idmarca == marca).ToList();
                }
                if (!string.IsNullOrEmpty(search))
                {
                    resultList = resultList.Where(i => i.descrizionebrevearticolo.ToUpper().Contains(search.ToUpper()) || i.codicearticolo.ToUpper().Contains(search.ToUpper())).ToList();
                }
                results.AddRange(resultList);
            }

            model.Products     = results.Skip(from).Take(12).ToList();
            model.ProductTotal = results.Count();
            model.ProductFrom  = from + 1;
            model.ProductTo    = from + pageLen;
            model.PageTotal    = (int)Math.Ceiling((double)model.ProductTotal / pageLen);
            model.CurrentPage  = page;
            model.CategoryDesc = _db.Marchegestite.Where(i => i.idmarca == marca).Select(i => i.descrizionemarca).FirstOrDefault();
            model.Category     = marca;
            model.Search       = search;

            return(View(model));
        }
Exemplo n.º 29
0
        public IActionResult Catalog(int id, int?pageSize, string drop, int page = 1)
        {
            var catalog = new ListProductViewModel();

            if (pageSize == null)
            {
                pageSize = _configuration.GetValue <int>("PageSize");
            }

            catalog.PageSize = pageSize;
            catalog.SortType = drop;
            if (id == 6)
            {
                catalog.Data = _productRepository.GetAllByMonth(id, 0, page, pageSize.Value);
            }

            else
            {
                catalog.Data = _productRepository.GetAllPaging(id, string.Empty, page, pageSize.Value);
            }
            catalog.Category = _productCategoryRepository.GetById(id);
            if (drop == "hightolow")
            {
                catalog.Data.Results = catalog.Data.Results.OrderByDescending(x => x.Price).ToList();
            }
            if (drop == "lowtohigh")
            {
                catalog.Data.Results = catalog.Data.Results.OrderByDescending(x => x.Price).Reverse().ToList();
            }
            if (drop == "atoz")
            {
                catalog.Data.Results = catalog.Data.Results.OrderByDescending(x => x.Name).Reverse().ToList();
            }
            if (drop == "ztoa")
            {
                catalog.Data.Results = catalog.Data.Results.OrderByDescending(x => x.Name).ToList();
            }
            return(View(catalog));
        }
Exemplo n.º 30
0
        public static List <SanPham> GetListProduct(ListProductViewModel viewModel)
        {
            CSQL objSQL = new CSQL(DatabaseProduct.connectionString);

            try
            {
                if (objSQL._OpenConnection() == false)
                {
                    throw new Exception("Không thể kết nối");
                }
                // input param
                if (viewModel.Tensp != null)
                {
                    SqlParameter prmTensp = new SqlParameter("@Tensp", SqlDbType.NVarChar, 50);
                    prmTensp.Direction = ParameterDirection.Input;
                    objSQL.Command.Parameters.Add(prmTensp);
                    prmTensp.Value = viewModel.Tensp;
                }

                SqlDataReader reader = objSQL.GetDataReaderFromSP("LIST_PRODUCT_GET");

                var     ListProduct = new List <SanPham>();
                SanPham SP;

                while (reader.Read())
                {
                    try
                    {
                        SP = new SanPham();
                        if (!reader.IsDBNull(reader.GetOrdinal("ID")))
                        {
                            SP.ID = reader.GetInt32(reader.GetOrdinal("ID"));
                        }
                        if (!reader.IsDBNull(reader.GetOrdinal("Tensp")))
                        {
                            SP.Tensp = reader.GetString(reader.GetOrdinal("Tensp"));
                        }
                        if (!reader.IsDBNull(reader.GetOrdinal("Gia")))
                        {
                            SP.Gia = reader.GetDouble(reader.GetOrdinal("Gia"));
                        }
                        if (!reader.IsDBNull(reader.GetOrdinal("MoTaSP")))
                        {
                            SP.MoTaSP = reader.GetString(reader.GetOrdinal("MoTaSP"));
                        }

                        ListProduct.Add(SP);
                    }
                    catch (Exception ex) {
                        ex.ToString();
                    }
                }

                return(ListProduct);
            }
            catch (Exception ex)
            {
                LogFile.Error(ex.ToString());   // Ghi thông tin ra file
            }
            finally
            {
                objSQL._CloseConnection();
            }

            return(new List <SanPham>());
        }