public ActionResult getproductinfor(int id) { SanPham item = db.SanPham.SingleOrDefault(t => t.ID == id); if (item != null) { SanPhamReturn sanpham = new SanPhamReturn { Ten = item.Ten, ID = item.ID, DonGia = item.DioGia, MoTa = item.MoTa, linkanh = item.linkanh }; return(Json(sanpham, JsonRequestBehavior.AllowGet)); } else { return(null); } }
public ActionResult sanpham(int id) { SanPham item = db.SanPham.SingleOrDefault(t => t.ID == id && t.TinhTrang == "ENABLE"); if (item != null) { SanPhamReturn sanpham = new SanPhamReturn { Ten = item.Ten, ID = item.ID, MoTa = item.MoTa, DonGia = item.DioGia, linkanh = item.linkanh, branch = item.ProductBranches.Name, isInstock = (item.SoLuong != 0 ? true : false), color = item.Color, size = item.Size }; List <SanPhamReturn> sameProduct = (from prduc in db.SanPham where prduc.Branches == item.Branches && prduc.TinhTrang == "ENABLE" select new SanPhamReturn() { ID = prduc.ID, Ten = prduc.Ten, DonGia = prduc.DioGia, brandID = prduc.ProductBranches.Id, branch = prduc.ProductBranches.Name, TypeID = (int)prduc.Type, TypeName = prduc.ProductTypes.Name, linkanh = prduc.linkanh } ).ToList(); ViewBag.sameProduct = sameProduct; return(View(sanpham)); } return(HttpNotFound()); }