Beispiel #1
0
        // GET: Product
        public ActionResult Index(string SearchString)
        {
            decimal s = 0;

            if (!String.IsNullOrEmpty(SearchString))
            {
                s = Convert.ToDecimal(SearchString);
            }
            PharmaTest_NREntities   entities          = new PharmaTest_NREntities();
            List <Product>          products          = entities.Products.ToList();
            List <ProductToDisplay> productToDisplays = new List <ProductToDisplay>();


            foreach (var p in products)
            {
                ProductToDisplay pr = new ProductToDisplay();
                pr.id           = p.id;
                pr.product_id   = p.product_id;
                pr.msr_prx      = p.msr_prx;
                pr.product_name = p.product_name;

                pr.purchase_prx = Convert.ToDecimal(p.purchase_prx);
                pr.manufacturer = p.manufacturer;
                productToDisplays.Add(pr);
            }
            if (s > 0)
            {
                productToDisplays = productToDisplays.Where(pr => pr.purchase_prx <= s).ToList();
            }
            var orderByManufacturer = from k in productToDisplays
                                      orderby k.manufacturer
                                      select k;

            return(View(orderByManufacturer));
        }
        public List <ProductToDisplay> Get_List_Product()
        {
            List <ProductToDisplay> lstProduct = new List <ProductToDisplay>();
            var product = dbproduct.Product.ToList();

            foreach (var item in product)
            {
                ProductToDisplay pro = new ProductToDisplay
                {
                    category     = contructorPro.get_Categories(item.id_cat),
                    description  = item.description,
                    price        = item.price,
                    product_id   = item.product_id,
                    status       = item.status,
                    product_name = item.product_name,
                    supplier     = contructorPro.get_Supplier(item.id_supplier),
                };
                lstProduct.Add(pro);
            }
            return(lstProduct);
        }