示例#1
0
        public JsonResult ListProduct()
        {
            MatHangService mh = new MatHangService();
            List <MATHANG> ds = mh.getAll().ToList();

            return
                (Json(
                     new
            {
                status = "true",
                ListProduct = ds.ToList()
                              .Select(p => new
                {
                    ID = p.ID,
                    TEN = p.TEN,
                    GIA = ((double)p.GIA).ToString("N0"),
                    KHUYENMAI = p.KHUYENMAI,
                    ANH = new ANHSPService().getAll().Where(z => z.MATHANGID == p.ID).FirstOrDefault().SRC,
                    NHASANXUAT = new NHASANXUATService().getAll().Where(z => z.ID == p.NHASANXUATID).FirstOrDefault().TEN,
                    LOAISANPHAM = new LOAISANPHAMService().getAll().Where(z => z.ID == p.LOAISANPHAMID).FirstOrDefault().TEN
                })
                              .ToList()
            }
                     ));
        }
示例#2
0
        public JsonResult ThongTinSanPham(int id)
        {
            MatHangService sv  = new MatHangService();
            MATHANG        mh  = sv.getAll().Where(p => p.ID == id).FirstOrDefault();
            ANHSP          anh = new ANHSPService().getAll().Where(p => p.MATHANGID == id).FirstOrDefault();

            return(Json(
                       new
            {
                TenSanPham = mh.TEN,
                MaSanPham = mh.MA,
                NhaSanXuatID = mh.NHASANXUATID,
                LoaiSanPhamID = mh.LOAISANPHAMID,
                GiaSanPham = mh.GIA,
                ChiTietSanPham = mh.CHITET,
                Anh = anh.SRC
            }
                       ));
        }