Exemplo n.º 1
0
        public ActionResult ProductRelatedList(int Id, int?Page)
        {
            int pageIndex = Page ?? 1;
            var model     = new RelatedProductSearchViewModel();
            var data      = _relatedProductService.GetList(x => x.ProductId1 == Id).ToList();

            List <RelatedProductListViewModel> list = new List <RelatedProductListViewModel>();

            foreach (var item in data)
            {
                foreach (var _pro in _productService.GetList(x => x.Id == item.ProductId2))
                {
                    RelatedProductListViewModel _related = new RelatedProductListViewModel();
                    _related.Id          = item.Id;
                    _related.ProductName = _pro.Name;
                    _related.BrandName   = _pro.Brand.Name;
                    _related.Published   = _pro.Published;
                    list.Add(_related);
                }
            }
            model.RelatedProductList = list.ToPagedList(pageIndex, 10);


            return(PartialView("_ProductRelatedList", model));
        }
Exemplo n.º 2
0
        public ActionResult RelatedProductPopup(RelatedProductSearchViewModel model)
        {
            int pageIndex = model.Page ?? 1;

            model.RelatedProductList = _productService.GetList(y =>
                                                               (string.IsNullOrEmpty(model.ProductName) || y.Name.ToLower().Contains(model.ProductName.ToLower()))
                                                               ).Select(x => new RelatedProductListViewModel
            {
                ProductId   = x.Id,
                ProductName = x.Name,
                Published   = x.Published,
                BrandName   = x.Brand.Name
            }).ToPagedList(pageIndex, 10);

            if (Request.IsAjaxRequest())
            {
                return(PartialView("_RelatedProductList", model));
            }
            return(PartialView("RelatedProductPopup", model));
        }