Exemplo n.º 1
0
        public List<ProductView> ViewAll()
        {
            using (var rep = new ProductRepository())
               {
               return rep.GetAll().Select(x => new ProductView
               {
                   Id = x.Id,
                   Name = x.Name,
                   Description = x.Description,
                   price = x.price,
                   SerialCode = x.SerialCode,
                   ImageUrl=x.ImageUrl,

                   ProdCategoryView = new ProdCategoryView()
                   {
                       CategoryId = x.CategoryId,
                       CategoryName = _cat.GetAll().ToList().Find(y => y.CategoryId == x.CategoryId).CategoryName,

                   },

                   ProdBrandView = new ProdBrandView()
                   {
                       BrandId = x.BrandId,
                       BrandName = _brand.GetAll().ToList().Find(y => y.BrandId == x.BrandId).BrandName,
                   }

               }).ToList();
               }
        }
Exemplo n.º 2
0
 public List<ProductView> Search(string SearchString)
 {
     using (var patientrepo = new ProductRepository())
        {
        return patientrepo.GetAll().Select(x => new ProductView() { Id = x.Id, Name = x.Name, Description = x.Description, price = x.price, ImageUrl = x.ImageUrl }).Where(s => s.Name.ToUpper().Contains(SearchString.ToUpper())
        || s.Name.ToUpper().Contains(SearchString.ToUpper())).ToList();
        }
 }