示例#1
0
        public ActionResult getgroupproductinfo(int id)
        {
            BoSanPham item = db.BoSanPham.SingleOrDefault(t => t.ID == id);

            if (item != null)
            {
                BoSanPhamInfoIndexModal sanpham = new BoSanPhamInfoIndexModal
                {
                    Ten = item.Ten,
                    id  = item.ID
                };

                List <ChiTietBoSanPham> chitiets = item.ChiTietBoSanPham.ToList();

                for (int i = 0; i < chitiets.Count; i++)
                {
                    SanPhamTrongBoSanPham pro = new SanPhamTrongBoSanPham();
                    pro.ID      = chitiets[i].IDSanPham;
                    pro.linkanh = chitiets[i].SanPham.linkanh;
                    pro.MoTa    = chitiets[i].SanPham.MoTa;
                    pro.Ten     = chitiets[i].SanPham.Ten;

                    sanpham.products.Add(pro);
                }
                return(Json(sanpham, JsonRequestBehavior.AllowGet));
            }
            else
            {
                return(null);
            }
        }
示例#2
0
        public ActionResult bosanpham(int id)
        {
            BoSanPham item = db.BoSanPham.SingleOrDefault(t => t.ID == id);

            if (item != null)
            {
                BoSanPhamInfoIndexModal sanpham = new BoSanPhamInfoIndexModal
                {
                    Ten  = item.Ten,
                    id   = item.ID,
                    Mota = item.Mota
                };

                List <ChiTietBoSanPham> chitiets = item.ChiTietBoSanPham.ToList();
                sanpham.products = new List <SanPhamTrongBoSanPham>();
                for (int i = 0; i < chitiets.Count; i++)
                {
                    SanPhamTrongBoSanPham pro = new SanPhamTrongBoSanPham();
                    pro.ID           = chitiets[i].IDSanPham;
                    pro.linkanh      = chitiets[i].SanPham.linkanh;
                    pro.MoTa         = chitiets[i].SanPham.MoTa;
                    pro.Ten          = chitiets[i].SanPham.Ten;
                    pro.GiaThuongMua = chitiets[i].SoLuongThuongMua;
                    pro.DonGia       = chitiets[i].SanPham.DioGia;

                    sanpham.products.Add(pro);
                }
                return(View(sanpham));
            }

            return(HttpNotFound());
        }