public ActionResult Edit(string Id) { if (HttpContext.Session != null && HttpContext.Session["Upload"] != null) { HttpContext.Session.Remove("Upload"); } var model = _factory.GetDetail(Id); return(PartialView("_Edit", model)); }
public ActionResult Detail(string id) { try { ProductDetailViewModels model = new ProductDetailViewModels(); if (!string.IsNullOrEmpty(id)) { var dataDetail = _fac.GetDetail(id); if (dataDetail != null) { dataDetail.ListImages = _fac.GetListImageOfProduct(id); if (dataDetail.ListImages != null) { dataDetail.ListImages.ForEach(x => { x.ImageURL = Commons.HostImage + "Products/" + x.ImageURL; }); } dataDetail.ListImages = dataDetail.ListImages.OrderBy(x => x.ImageURL).Skip(0).Take(4).ToList(); var oldData = _fac.GetList().Where(x => !x.Id.Equals(id) && x.CategoryId.Equals(dataDetail.CategoryId)).OrderBy(x => x.CreatedDate).Skip(0).Take(5).ToList(); if (oldData != null && oldData.Any()) { var dataImage = _fac.GetListImage(); oldData.ForEach(x => { var _Image = dataImage.FirstOrDefault(y => y.ProductId.Equals(x.Id)); if (_Image != null) { if (!string.IsNullOrEmpty(_Image.ImageURL)) { x.ImageURL = Commons.HostImage + "Products/" + _Image.ImageURL; } } }); } model.ListProduct = oldData; model.Product = dataDetail; return(View(model)); } else { return(RedirectToAction("Index", "Home")); } } else { return(RedirectToAction("Index")); } } catch (Exception ex) { //NSLog.Logger.Error("GetDetail: ", ex); return(new HttpStatusCodeResult(400, ex.Message)); } }
// 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)); }
public CMS_ProductsModels GetDetail(string Id) { return(_factory.GetDetail(Id)); }