示例#1
0
        public ActionResult GetProductList(string catId, int?page, string record1, string ShortBy, string[] checkedValues)
        {
            try
            {
                int pageSize = 0;
                if (string.IsNullOrEmpty(record1))
                {
                    pageSize = Convert.ToInt32(record1);
                }
                else
                {
                    pageSize = Convert.ToInt32(record1);
                }
                var Products = ITMMASTCRUD.GetProductByCatId(catId.Trim());

                ViewBag.RecordPerPage = pageSize;
                ViewBag.TotalRecord   = Products.Count();

                if (ShortBy == "Low to High")
                {
                    Products = Products.OrderBy(x => x.Sale_Price).ToList();
                }
                else
                {
                    Products = Products.OrderByDescending(x => x.Sale_Price).ToList();
                }

                if (checkedValues != null)
                {
                    Products = Products.Where(x => checkedValues.Any(a => a.ToString() == x.BrandId)).ToList();
                }

                var pager = new Pager(Products.Count(), page, pageSize);
                pager.catId = catId;

                var viewModel = new IndexViewModel
                {
                    Items = Products.Skip((pager.CurrentPage - 1) * pager.PageSize).Take(pager.PageSize).ToList(),

                    Pager = pager
                };
                return(PartialView("_ProductListing", viewModel));
            }
            catch (Exception ex)
            {
                ExceptionLogDomain obj = new ExceptionLogDomain();
                obj.MethodName     = "GetProductList";
                obj.ControllerName = "Product";
                obj.ErrorText      = ex.Message;
                obj.StackTrace     = ex.StackTrace;
                obj.Datetime       = DateTime.Now;

                ExceptionLogCRUD.AddToExceptionLog(obj);
                return(RedirectToAction("Index", "Error"));
            }
        }
示例#2
0
        public ActionResult ProductDetail(string ProdId, string catId)
        {
            try
            {
                var           data           = ITMMASTCRUD.GetProductById(ProdId);
                ITMMASTDomain mITMMASTDomain = new ITMMASTDomain();

                mITMMASTDomain.DetailDesc  = data[0].DetailDesc;
                mITMMASTDomain.GRP_CD      = data[0].GRP_CD;
                mITMMASTDomain.Item_CD     = data[0].Item_CD;
                mITMMASTDomain.Item_Desc   = data[0].Item_Desc;
                mITMMASTDomain.Offer_Price = data[0].Offer_Price;
                mITMMASTDomain.Sale_Price  = data[0].Sale_Price;
                if (Session["QTY"] != null)
                {
                    mITMMASTDomain.Qty = Session["QTY"].ToString();
                }
                else
                {
                    mITMMASTDomain.Qty = "1";
                }


                var relatedProduct = ITMMASTCRUD.GetProductByCatId(catId.Trim());

                ViewBag.relatedProducts = relatedProduct.SkipWhile(a => a.Item_CD != ProdId).ToList();

                return(View(mITMMASTDomain));
            }
            catch (Exception ex)
            {
                ExceptionLogDomain obj = new ExceptionLogDomain();
                obj.MethodName     = "GetProductList";
                obj.ControllerName = "Product";
                obj.ErrorText      = ex.Message;
                obj.StackTrace     = ex.StackTrace;
                obj.Datetime       = DateTime.Now;

                ExceptionLogCRUD.AddToExceptionLog(obj);
                return(RedirectToAction("Index", "Error"));
            }
        }