Ejemplo n.º 1
0
        public ActionResult GetProductForCategory(byte?categoryId)
        {
            QuickKartRepository repObj = new QuickKartRepository();

            ViewBag.CategoryList = repObj.GetCategoriesUsinglinq();
            if (categoryId != null)
            {
                Session["categoryId"] = categoryId;
            }
            else
            {
                categoryId = Convert.ToByte(Session["categoryId"]);
            }
            ViewBag.SelectedCategory = repObj.GetCategoriesUsinglinq().Where(x => x.CategoryId == categoryId).Select(x => x.CategoryName).FirstOrDefault();
            if (ViewBag.SelectedCategory == null)
            {
                ViewBag.SelectedCategory = "--Select--";
            }
            var productList = repObj.GetProductUsingLinq();
            var mapObj      = new MyMapper <Product, Models.Product>();
            var products    = new List <Models.Product>();

            foreach (var product in productList)
            {
                products.Add(mapObj.Translate(product));
            }
            var filteredProducts = products.Where(model => model.CategoryId == categoryId);

            return(View(filteredProducts));
        }
Ejemplo n.º 2
0
        public ActionResult ViewCategory()
        {
            category = rep.GetCategoriesUsinglinq();
            foreach (var item in category)
            {
                mCategory.Add(mapObj.Translate(item));
            }

            return(View(mCategory));
        }