Exemplo n.º 1
0
        public List <ProductDtoViewModel> Get(ProductDtoSearchModel model)
        {
            var query = Context.Product.AsQueryable();

            if (!string.IsNullOrEmpty(model.Name))
            {
                query = query.Where(r => r.Name.Contains(model.Name));
            }


            var result = query.OrderByDescending(r => r.ID).Select(p => new ProductDtoViewModel
            {
                Name = p.Name,
                Slug = p.Name,
            }).ToList();

            return(result);
        }
Exemplo n.º 2
0
        public ResponseModel <ProductDtoViewModel> GetAll(ProductDtoSearchModel model)
        {
            var query = Context.Product.AsQueryable();

            if (!string.IsNullOrEmpty(model.Name))
            {
                query = query.Where(r => r.Name.Contains(model.Name));
            }


            var result = query.OrderByDescending(r => r.ID).Select(p => new ProductDtoViewModel
            {
                //ID = p.ID,
                Name = p.Name,
            }).ToList();

            return(new ResponseModel <ProductDtoViewModel>((int)Enums.ResponseCode.SUCCESS, result));
        }