示例#1
0
        public IEnumerable <Product> GetAllProduct(out int totalRecords,
                                                   int currentPage = 1,
                                                   int pageSize    = 25,
                                                   string sortBy   = "Id",
                                                   bool descending = true)
        {
            var spec = ProductQuery.WithAll();

            totalRecords = _product.Count(spec);
            var sort = Context.Filters.Sort <Product, int>(ti => ti.Id, true);

            switch (sortBy)
            {
            case "Id":
                sort = Context.Filters.Sort <Product, int>(ti => ti.Id, descending);
                break;

            default:
                break;
            }
            var pager = Context.Filters.Page <Product>(currentPage, pageSize);

            return(_product.Find(spec, sort, pager));
        }
示例#2
0
 public IEnumerable <Product> GetByAccountId(int accountId)
 {
     return(_product.Find(ProductQuery.WithByAccountId(accountId)));
 }
示例#3
0
 public Product GetByCode(string code)
 {
     return(_product.Find(ProductQuery.WithByCode(code)).FirstOrDefault());
 }
示例#4
0
 public Product GetByProName(string proName)
 {
     return(_product.One(ProductQuery.WithByProName(proName)));
 }
示例#5
0
 public Product GetById(int id)
 {
     return(_product.One(ProductQuery.WithById(id)));
 }