Beispiel #1
0
 public IHttpActionResult SanPham10([FromBody] PhanTrang pt)// phanTrang{id, Trang, Size}
 {
     try
     {
         List <SanPham> lsp = new List <SanPham>();
         if (pt.locTheo == 0) //gia tu thap den cao
         {
             lsp = db.SanPhams.Where(x => x.id_danh_muc == pt.id && x.trang_thai == true).OrderBy(e => e.gia_km).ToList().ToPagedList(pt.trang, pt.size).ToList();
         }
         if (pt.locTheo == 1) //gia tu cao den thap
         {
             lsp = db.SanPhams.Where(x => x.id_danh_muc == pt.id && x.trang_thai == true).OrderByDescending(e => e.gia_km).ToList().ToPagedList(pt.trang, pt.size).ToList();
         }
         if (pt.locTheo == 2) //phan tram khuyen mai cao nhat
         {
             lsp = db.SanPhams.Where(x => x.id_danh_muc == pt.id && x.trang_thai == true).OrderByDescending(e => e.phan_tram_km).ToList().ToPagedList(pt.trang, pt.size).ToList();
         }
         if (lsp.Count == 0)
         {
             return(StatusCode(HttpStatusCode.NoContent));
         }
         List <dynamic> obj = new List <dynamic>();
         for (int i = 0; i < lsp.Count; i++)
         {
             var tam = new
             {
                 id_san_pham    = lsp[i].id_san_pham,
                 id_danh_muc    = lsp[i].id_danh_muc,
                 ten_sp         = lsp[i].ten_sp,
                 gia_sp         = lsp[i].gia_sp,
                 phan_tram_km   = lsp[i].phan_tram_km,
                 gia_km         = lsp[i].gia_km,
                 so_luong       = lsp[i].so_luong,
                 mo_ta          = lsp[i].mo_ta,
                 url_hinh_chinh = "http://www.3anhem.somee.com" + lsp[i].url_hinh_chinh
             };
             obj.Add(tam);
         }
         return(Ok(obj));
     }
     catch (Exception ex)
     {
         return(BadRequest(ex.Message));
     }
 }
        // GET: api/ThongSoKyThuats
        public PhanTrang <ThongSoKyThuat_OBJ> GetALL(int trang, int SoBanGhi)
        {
            ThongSoKyThuat_BUS bus = new ThongSoKyThuat_BUS();
            int DoDaiDanhSach      = 0;
            var DanhSach           = bus.HienThiThongSoKyThuat();

            DoDaiDanhSach = DanhSach.Count();

            var TrangSanPham = DanhSach.OrderByDescending(x => x.MaSanPham).Skip(trang * SoBanGhi).Take(SoBanGhi);

            var PhanTrang = new PhanTrang <ThongSoKyThuat_OBJ>()
            {
                DanhSach = TrangSanPham,
                Trang    = trang,
                SoBanGhi = SoBanGhi,
                SoTrang  = (int)Math.Ceiling((decimal)DoDaiDanhSach / SoBanGhi)
            };

            return(PhanTrang);
        }
Beispiel #3
0
        public IHttpActionResult getsanPhamPhanTrang([FromBody] PhanTrang phanTrang)
        {
            try
            {
                List <SanPhamYeuThich> list = db.SanPhamYeuThiches.Where(x => x.id_khach_hang == phanTrang.id).ToPagedList(phanTrang.trang, phanTrang.size).ToList();
                List <dynamic>         tam  = new List <dynamic>();
                if (list.Count == 0)
                {
                    return(StatusCode(HttpStatusCode.NoContent));
                }
                for (int i = 0; i < list.Count; i++)
                {
                    SanPham sp    = db.SanPhams.FirstOrDefault(e => e.id_san_pham == list[i].id_san_pham);
                    var     spTam = new
                    {
                        id_san_pham    = sp.id_san_pham,
                        id_danh_muc    = sp.id_danh_muc,
                        ten_sp         = sp.ten_sp,
                        so_luong       = sp.so_luong,
                        url_hinh_chinh = "http://www.3anhem.somee.com" + sp.url_hinh_chinh,
                        mo_ta          = sp.mo_ta,
                        phan_tram_km   = sp.phan_tram_km,
                        gia_sp         = sp.gia_sp,
                        gia_km         = sp.gia_km
                    };
                    var spyt = new
                    {
                        idKhachHang = list[i].id_khach_hang,
                        idSanPham   = list[i].id_san_pham,
                        idYeuThich  = list[i].id_yeu_thich,
                        sanPham     = spTam
                    };

                    tam.Add(spyt);
                }
                return(Ok(tam));
            }catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
        public PhanTrang <LoaiSanPham_OBJ> GetAll(int trang, int SoBanGhi, string TuKhoa)
        {
            LoaiSanPham_BUS bus           = new LoaiSanPham_BUS();
            int             DoDaiDanhSach = 0;

            var DanhSach = bus.TimKiemThongTinSanPham(TuKhoa);

            DoDaiDanhSach = DanhSach.Count();

            var TrangLoaiSanPham = DanhSach.OrderByDescending(x => x.MaLoaiSanPham).Skip(trang * SoBanGhi).Take(SoBanGhi);

            var PhanTrang = new PhanTrang <LoaiSanPham_OBJ>()
            {
                DanhSach = TrangLoaiSanPham,
                Trang    = trang,
                SoBanGhi = SoBanGhi,
                SoTrang  = (int)Math.Ceiling((decimal)DoDaiDanhSach / SoBanGhi)
            };

            return(PhanTrang);
        }
        //[Route("getall")]
        public PhanTrang <SanPham_OBJ> GetAll(int MaNhaSanXuat, int trang, int SoBanGhi)
        {
            int DoDaiDanhSach = 0;

            SanPham_BUS bus      = new SanPham_BUS();
            var         DanhSach = bus.TimKiemThongTinTheoNhaSanXuat(MaNhaSanXuat);

            DoDaiDanhSach = DanhSach.Count();

            var TrangSanPham = DanhSach.OrderByDescending(x => x.MaSanPham).Skip(trang * SoBanGhi).Take(SoBanGhi);

            var PhanTrang = new PhanTrang <SanPham_OBJ>()
            {
                DanhSach = TrangSanPham,
                Trang    = trang,
                SoBanGhi = SoBanGhi,
                SoTrang  = (int)Math.Ceiling((decimal)DoDaiDanhSach / SoBanGhi)
            };

            return(PhanTrang);
        }
Beispiel #6
0
        // GET: api/LoaiSanPhams
        public PhanTrang <TaiKhoan_OBJ> GetAll(int trang, int SoBanGhi)
        {
            TaiKhoan_BUS bus           = new TaiKhoan_BUS();
            int          DoDaiDanhSach = 0;

            var DanhSach = bus.HienThiDanhSachTaiKhoan();

            DoDaiDanhSach = DanhSach.Count();

            var TrangLoaiSanPham = DanhSach.OrderByDescending(x => x.NgayTao).Skip(trang * SoBanGhi).Take(SoBanGhi);


            var PhanTrang = new PhanTrang <TaiKhoan_OBJ>()
            {
                DanhSach = TrangLoaiSanPham,
                Trang    = trang,
                SoBanGhi = SoBanGhi,
                SoTrang  = (int)Math.Ceiling((decimal)DoDaiDanhSach / SoBanGhi)
            };

            return(PhanTrang);
        }
Beispiel #7
0
        public IHttpActionResult getListHoaDon([FromBody] PhanTrang phanTrang)
        {
            try
            {
                //
                List <DonDatHang>   list = db.DonDatHangs.Where(x => x.id_khach_hang == phanTrang.id).ToPagedList(phanTrang.trang, phanTrang.size).ToList();
                List <HTListHoaDon> lhd  = new List <HTListHoaDon>();
                if (list == null)
                {
                    return(StatusCode(HttpStatusCode.NoContent));
                }
                for (int i = 0; i < list.Count; i++)
                {
                    HTListHoaDon hoaDonTam = new HTListHoaDon();
                    // tao dia chi noi nhan hang
                    DiaChiKhachHang dc     = db.DiaChiKhachHangs.FirstOrDefault(e => e.id == list[i].id_dia_chi);
                    TinhThanh       tinh   = db.TinhThanhs.FirstOrDefault(x => x.ma_tinh == dc.id_tinh);
                    QuanHuyen       quan   = db.QuanHuyens.FirstOrDefault(x => x.ma_quan_huyen == dc.id_quan);
                    XaPhuong        xa     = db.XaPhuongs.FirstOrDefault(x => x.ma_xa_phuong == dc.id_xa_phuong);
                    string          diaChi = "" + dc.dia_chi + ", " + xa.ten + ", " + quan.ten_quan_huyen + ", " + tinh.ten;

                    hoaDonTam.id        = list[i].id_don_hang;
                    hoaDonTam.KhachHang = db.KhachHangs.FirstOrDefault(e => e.id_khach_hang == list[i].id_khach_hang).ten_nguoi_dung;
                    hoaDonTam.TinhTrang = db.TinhTrangDonHangs.FirstOrDefault(e => e.id_tinh_trang == list[i].id_tinh_trang).tinh_trang_don_hang;
                    hoaDonTam.ngayLap   = list[i].ngay_lap.ToShortDateString();
                    hoaDonTam.DiaChi    = diaChi;
                    hoaDonTam.soDT      = list[i].so_dt_nguoi_nhan;
                    hoaDonTam.tongGia   = (float)list[i].tong_tien;
                    hoaDonTam.ghiChu    = list[i].ghi_chu;
                    lhd.Add(hoaDonTam);
                }
                return(Ok(lhd));
            }catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }