Ejemplo n.º 1
0
        public List <SanPhamViewModel> Search(string id, string searchValue, string status)
        {
            var            a  = _sanPhamRepository.ReadSanPham(id);
            List <SanPham> rs = new List <SanPham>();

            if (!string.IsNullOrEmpty(status))
            {
                // a = context.SanPham.Where(x=>x.LoaiSp == id && x.Status == Int32.Parse(status)).ToList();
                a = _sanPhamRepository.GetSanPhamsByIdStatus(id, status);
            }
            if (!String.IsNullOrEmpty(searchValue))
            {
                foreach (var item in a)
                {
                    if (item.TenSp.ToLower().Contains(searchValue.ToLower().Trim()) || item.MaSp.ToLower().Contains(searchValue.ToLower().Trim()))
                    {
                        rs.Add(item);
                    }
                }
                return(_mapper.Map <List <SanPhamViewModel> >(rs));
            }
            return(_mapper.Map <List <SanPhamViewModel> >(a));
        }