public virtual OperationResult FindAll(SelectParam selectParam, int?page, int?size)
        {
            if (page == 0)
            {
                page = null;
            }

            if (size == 0)
            {
                size = null;
            }
            try
            {
                if (selectParam != null)
                {
                    selectParam = this.SetAdditionalParameter(selectParam);
                }
                List <T> items = repo.FindAll(selectParam, page, size);
                return(new OperationResult(true, items));
            }
            catch (Exception e)
            {
                return(new OperationResult(false, null, e.Message));
            }
        }
 public virtual OperationResult GetTotal(SelectParam selectParam)
 {
     try
     {
         Int64 total = repo.GetTotal(selectParam);
         return(new OperationResult(true, total));
     }
     catch (Exception e)
     {
         return(new OperationResult(false, e, e.Message));
     }
 }
Exemple #3
0
        public virtual Int64 GetTotal(SelectParam selectParam)
        {
            Int64 total = 0;

            if (selectParam != null && selectParam.Where != null)
            {
                total = context.Set <T>().Where(selectParam.Where).Count();
            }
            else
            {
                total = context.Set <T>().Count();
            }
            return(total);
        }
        public OperationResult FindAll(string keyword, int page, int size)
        {
            SelectParam selectParam = new SelectParam();

            selectParam.Keyword = keyword;
            if (keyword == "all")
            {
                selectParam.Keyword = null;
            }

            IBusinessService <T> businessService = Factory.Create <IBusinessService <T> >(this.Key, ClassType.clsTypeBusinessService);
            OperationResult      result          = businessService.FindAllByKeyword(selectParam, page, size);

            return(result);
        }
Exemple #5
0
        public virtual List <T> FindAll(SelectParam selectParam, int?page, int?size)
        {
            List <T> items = null;

            if (selectParam != null && selectParam.OrderBy.Count == 0)
            {
                PropertyInfo prop = Trakindo.Utility.Assembly.GetKeyProperty(typeof(T));
                if (prop != null)
                {
                    selectParam.AddOrderBy(prop.Name);
                }
            }

            if (page == null || size == null)
            {
                if (selectParam != null && selectParam.Where != null)
                {
                    items = context.Set <T>().Where(selectParam.Where).OrderBy(selectParam.OrderByString).ToList <T>();
                }
                else if (selectParam != null)
                {
                    items = context.Set <T>().OrderBy(selectParam.OrderByString).ToList <T>();
                }
                else
                {
                    items = context.Set <T>().ToList <T>();
                }
            }
            else
            {
                if (selectParam != null && selectParam.Where != null && selectParam.Where.Length > 0)
                {
                    items = context.Set <T>().Where(selectParam.Where).OrderBy(selectParam.OrderByString).Skip((int)(page - 1) * (int)size).Take((int)size).ToList <T>();
                }
                else if (selectParam != null)
                {
                    items = context.Set <T>().OrderBy(selectParam.OrderByString).Skip((int)(page - 1) * (int)size).Take((int)size).ToList <T>();
                }
                else
                {
                    items = context.Set <T>().ToList <T>();
                }
            }


            return(items);
        }
 protected virtual SelectParam SetAdditionalParameter(SelectParam selectParam)
 {
     return(selectParam);
 }
 public virtual OperationResult FindAllByKeyword(SelectParam selectParam, int?page, int?size)
 {
     string where      = GetPredicateByKeyword(selectParam.Keyword);
     selectParam.Where = where;
     return(this.FindAll(selectParam, page, size));
 }