Exemplo n.º 1
0
        public ActionResult _LoadProduct(SearchDealModel model)
        {
            model.PageIndex = model.PageIndex == 0 ? 1 : model.PageIndex;
            var query = _dealRepository.GetDealList();

            if (!string.IsNullOrEmpty(model.DealType))
            {
            }
            if (!string.IsNullOrEmpty(model.Sort))
            {
            }
            if (!string.IsNullOrEmpty(model.Search))
            {
                query = query.Where(x => x.ProductName.Contains(model.Search));
            }

            model.TotalRecordCount = query.Count();
            var _getList  = query.OrderBy(a => a.DealId).Skip(((model.PageIndex - 1) * model.PageSize)).Take(model.PageSize).ToList();
            int pageCount = (model.TotalRecordCount / model.PageSize) + ((model.TotalRecordCount % model.PageSize) > 0 ? 1 : 0);

            model.TotalPageCount = pageCount;
            // bind schemes
            foreach (var item in _getList)
            {
                item.lstSchemes = _schemeRepository.FindBy(x => x.DealId == item.DealId).ToList();
            }
            model.getDealModels = _getList;

            return(PartialView(model));
        }
Exemplo n.º 2
0
        public ActionResult Index()
        {
            if (UserAuthenticate.IsAuthenticated)
            {
                int _role = UserAuthenticate.Role;
                if (_role == (int)Roles.Admin)
                {
                    return(RedirectToAction("Dashboard", "Admin"));
                }
                //return RedirectToAction("Index", "Account");
            }

            SearchDealModel model = new SearchDealModel();

            model.PageIndex = model.PageIndex == 0 ? 1 : 1;
            var lstPazeSize = new List <SelectListItem>
            {
                new SelectListItem {
                    Text = "8", Value = "8"
                },
                new SelectListItem {
                    Text = "12", Value = "12"
                },
                new SelectListItem {
                    Text = "16", Value = "16"
                },
                new SelectListItem {
                    Text = "20", Value = "20"
                },
            };

            var lstDealType = new List <SelectListItem>
            {
                new SelectListItem {
                    Text = "All Deals", Value = "1"
                },
                new SelectListItem {
                    Text = "Trending Deals", Value = "2"
                },
                new SelectListItem {
                    Text = "Regular Deals", Value = "3"
                },
                new SelectListItem {
                    Text = "Local Deals", Value = "4"
                },
                new SelectListItem {
                    Text = "Bulk deals", Value = "5"
                },
                new SelectListItem {
                    Text = "Regular Products", Value = "6"
                }
            };

            var lstSorting = new List <SelectListItem>
            {
                new SelectListItem {
                    Text = "Recent Deals", Value = "1"
                },
                new SelectListItem {
                    Text = "Closing Soon", Value = "2"
                },
                new SelectListItem {
                    Text = "Closing Late", Value = "3"
                },
                new SelectListItem {
                    Text = "Product Name A to Z", Value = "4"
                },
                new SelectListItem {
                    Text = "Product Name Z to A", Value = "5"
                },
                new SelectListItem {
                    Text = "Rate Low to High", Value = "6"
                },
                new SelectListItem {
                    Text = "Rate High to Low", Value = "7"
                }
            };

            ViewBag.BindPageSize = new SelectList(lstPazeSize, "Value", "Text", model.PageSize);
            ViewBag.BindDealType = new SelectList(lstDealType, "Value", "Text", model.DealType);
            ViewBag.BindSorting  = new SelectList(lstSorting, "Value", "Text", model.Sort);

            return(View(model));
        }