// GET: Product public ActionResult Index(string product_id) { NSLog.Logger.Info("Request_Product_Index", product_id); var models = new ProductDetailViewModels(); try { if (string.IsNullOrEmpty(product_id)) { return(RedirectToAction("Index", "Home")); } var _product = _fac.GetDetail(product_id); if (_product != null) { var data = _fac.GetList().Where(o => o.ProductTypeCode == (int)CMS_Common.Commons.EProductType.Product && o.IsActive).ToList(); if (data != null) { /* get list product by category */ models.ListProduct = data.Where(o => o.CategoryId.Equals(_product.CategoryId) && !o.Id.Equals(product_id)).ToList(); /* get top 3 product new */ models.ProductNew = data.OrderByDescending(x => x.CreatedDate).Skip(0).Take(3).ToList(); /* get list product category */ var _cate = _facCate.GetListProductCate(); models.Product = _product; if (models.Product != null) { models.Product.ImageURL = models.Product.ListImages != null && models.Product.ListImages.Count > 0 ? models.Product.ListImages.FirstOrDefault().ImageURL : ""; } models.Categories = _cate; } } } catch (Exception ex) { NSLog.Logger.Error("Index Product", ex); } return(View(models)); }
// GET: Shop public ActionResult Index() { var models = new CMS_ShopViewModels(); try { var data = _fac.GetList(); if (data != null) { models.ProductNew = data.Where(o => o.IsActive).OrderByDescending(x => x.CreatedDate).Skip(0).Take(3).ToList(); } var _cate = _facCate.GetListProductCate(); models.Products = data; models.Categories = _cate; } catch (Exception ex) { NSLog.Logger.Error("Index Shop", ex); } return(View(models)); }