Beispiel #1
0
        public IList <BaoCaoHangHoaViewModel> ListView(string nhanVienCode, bool trangThai)
        {
            IQueryable <HangHoa>          danhSachHangHoa     = _hangHoaRepo.GetAll();
            IQueryable <LoaiHangHoa>      danhSachLoaiHangHoa = _loaiHangHoaRepo.GetAll();
            List <BaoCaoHangHoaViewModel> allForManager       = new List <BaoCaoHangHoaViewModel>();

            allForManager = (from hangHoa in danhSachHangHoa
                             join loaiHangHoa in danhSachLoaiHangHoa
                             on hangHoa.MaLoaiHangHoa equals loaiHangHoa.MaLoaiHangHoa
                             where hangHoa.TrangThai == trangThai
                             select new
            {
                MaHangHoa = hangHoa.MaHangHoa,
                TenHangHoa = hangHoa.TenHangHoa,
                TenLoaiHangHoa = loaiHangHoa.TenLoaiHangHoa,
                GiaBan = hangHoa.GiaBan,
                GiamGia = hangHoa.GiamGia,
                TrangThai = hangHoa.TrangThai,
                SoLuongTon = hangHoa.SoLuongTon,
                ModelName = hangHoa.ModelName
            }).AsEnumerable().Select(x => new BaoCaoHangHoaViewModel()
            {
                maHangHoa      = x.MaHangHoa,
                tenHangHoa     = x.TenHangHoa,
                tenLoaiHangHoa = x.TenLoaiHangHoa,
                giaBan         = x.GiaBan,
                giamGia        = x.GiamGia,
                trangThai      = x.TrangThai,
                soLuongTon     = x.SoLuongTon,
                modelName      = x.ModelName
            }).OrderBy(x => x.maHangHoa).ToList();
            return(allForManager);
        }
Beispiel #2
0
        public IList <HangHoaViewModel> SearchDanhSachHangHoa(String key, string trangThai)
        {
            IQueryable <HangHoa>    danhSachHangHoa = _hangHoaRepo.GetAll();
            List <HangHoaViewModel> all             = new List <HangHoaViewModel>();

            all = (from hanghoa in danhSachHangHoa
                   join loaihanghoa in _loaiHangHoaRepo.GetAll()
                   on hanghoa.MaLoaiHangHoa equals loaihanghoa.MaLoaiHangHoa
                   where (hanghoa.TrangThai.ToString().Equals(trangThai) ||
                          hanghoa.TenHangHoa.ToString().Contains(key) ||
                          hanghoa.ModelName.ToString().Contains(key) ||
                          loaihanghoa.TenLoaiHangHoa.ToString().Contains(key))
                   select new
            {
                MaHangHoa = hanghoa.MaHangHoa,
                TenHangHoa = hanghoa.TenHangHoa,
                GiaBan = hanghoa.GiaBan,
                GiamGia = hanghoa.GiamGia,
                SoLuongTon = hanghoa.SoLuongTon,
                XuatXu = hanghoa.XuatXu,
                ThoiGianBaoHanh = hanghoa.ThoiGianBaoHanh,
                MaLoaiHangHoa = loaihanghoa.MaLoaiHangHoa,
                TenLoaiHangHoa = loaihanghoa.TenLoaiHangHoa,
                ModelName = hanghoa.ModelName,
                TrangThai = hanghoa.TrangThai,
                HinhAnh = hanghoa.HinhAnh,
            }).AsEnumerable().Select(x => new HangHoaViewModel()
            {
                maHangHoa       = x.MaHangHoa,
                tenHangHoa      = x.TenHangHoa,
                giaBan          = x.GiaBan,
                giamGia         = x.GiamGia,
                soLuongTon      = x.SoLuongTon,
                xuatXu          = x.XuatXu,
                thoiGianBaoHanh = x.ThoiGianBaoHanh,
                maLoaiHangHoa   = x.MaLoaiHangHoa,
                tenLoaiHangHoa  = x.TenLoaiHangHoa,
                modelName       = x.ModelName,
                trangThai       = x.TrangThai,
                hinhAnh         = x.HinhAnh,
            }).ToList();

            return(all);
        }
        public IList <LoaiHangHoa> LoadDSLoaiHangHoa()
        {
            IQueryable <LoaiHangHoa> loaiHangHoa = _loaiHangHoaRepo.GetAll();

            return(loaiHangHoa.ToList());
        }