Exemplo n.º 1
0
        public JsonResult UserTypeTableAjax(JQueryDataTableParamModel param)
        {
            #region byDefaultReturnData

            int rowCount   = 0;
            int lnRowCount = 0;
            var result     = from q in new List <UserType>()
                             select new
            {
                q.Id,
                q.Name
            };

            #endregion
            var oUserType = new UserType();
            if (!string.IsNullOrEmpty(Request.QueryString["Name"]))
            {
                oUserType.Name = Request.QueryString["Name"];
            }

            DataTableProcessModel m         = new DataTableProcessModel();
            DataTableProcessModel dtProcess = DataTableProcesses.DataTableEslestir(param, m);
            //oUserType.SortCol = dtProcess.SortCol;
            //oUserType.SortType = dtProcess.SortType;
            //oUserType.Page = dtProcess.Page;
            //oUserType.RowPerPage = dtProcess.RowPerPage;
            //var oResultModel = DAL.Account.UserType.GetUserType(oUserType);

            var filters = new Filters <UserType>();
            //filters.Add(Convert.ToBoolean(oUserType.Name), x => x.Name == oUserType.Name);
            filters.Add(true, x => x.IsDeleted == false);

            var sorts = new Sorts <UserType>();
            sorts.Add(dtProcess.SortCol == "Id", x => x.Name);

            var getUsers = _db.UserTypes.Paginate(dtProcess.Page, dtProcess.RowPerPage, sorts, filters);

            if (getUsers.RecordCount > 0)
            {
                var lstUserType = getUsers.Results;

                rowCount   = getUsers.RecordCount;
                lnRowCount = rowCount;

                result = from q in lstUserType
                         select new
                {
                    q.Id,
                    q.Name
                };
            }
            return(Json(new
            {
                param.sEcho,
                iTotalRecords = rowCount,
                iTotalDisplayRecords = lnRowCount,
                aaData = result
            },
                        JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 2
0
        public async Task <TransactionHistoryPage <TransactionHistory> > GetEvents(TransactionHistoryQuery transactionHistoryQuery)
        {
            if (transactionHistoryQuery.From != null)
            {
                transactionHistoryQuery.From = transactionHistoryQuery.From.Value.ToUniversalTime();
            }
            if (transactionHistoryQuery.To != null)
            {
                transactionHistoryQuery.To = transactionHistoryQuery.To.Value.ToUniversalTime();
            }

            var sorts = new Sorts <Data.Models.TransactionHistory>();

            sorts.Add(true, x => x.OccuredAt, true);

            var filters = new Filters <Data.Models.TransactionHistory>();

            filters.Add(!string.IsNullOrEmpty(transactionHistoryQuery.NodeId), x => x.NodeId == transactionHistoryQuery.NodeId);
            filters.Add(transactionHistoryQuery.NodeIds != null && transactionHistoryQuery.NodeIds.Any(), x => transactionHistoryQuery.NodeIds.Contains(x.NodeId));
            filters.Add(transactionHistoryQuery.From != null, x => x.OccuredAt > transactionHistoryQuery.From);
            filters.Add(transactionHistoryQuery.To != null, x => x.OccuredAt < transactionHistoryQuery.To);

            var result = await _transactionHistoryRepository.GetTransactionHistory(transactionHistoryQuery.CurrentPage, transactionHistoryQuery.PageSize, sorts, filters);

            return(_mapper.Map <TransactionHistoryPage <TransactionHistory> >(result));
        }
Exemplo n.º 3
0
 private void SetOrderByForMember(MemberExpression memberExp, LambdaExpression fullExpression, SortType sortType)
 {
     if (memberExp.Expression.NodeType == ExpressionType.MemberAccess)
     {
         //分组查询
         if (IsGroupBy)
         {
             var descriptor = GroupByPropertyList.FirstOrDefault(m => m.Alias == memberExp.Member.Name);
             if (descriptor != null)
             {
                 var colName = GetColumnName(descriptor.Name, descriptor.JoinDescriptor);
                 Sorts.Add(new Sort(colName, sortType));
             }
         }
         else
         {
             if (memberExp.Expression.Type.IsString())
             {
                 var memberName = memberExp.Member.Name.Equals("Length");
                 //解析Length函数
                 if (memberName)
                 {
                     var funcName = _sqlAdapter.FuncLength;
                     var colName  = GetColumnName(memberExp.Expression as MemberExpression, fullExpression);
                     Sorts.Add(new Sort($"{funcName}({colName})", sortType));
                 }
             }
         }
     }
     else
     {
         var colName = GetColumnName(memberExp, fullExpression);
         Sorts.Add(new Sort(colName, sortType));
     }
 }
Exemplo n.º 4
0
 ///<inheritdoc/>
 public IOrderQuery <SelectQuery> OrderBy(params IOrder[] sorts)
 {
     foreach (IOrder sort in sorts)
     {
         Sorts.Add(sort);
     }
     return(this);
 }
        public async Task <Page <WebsiteViewData> > GetPaginatedResultsAsync(int pageSize, int currentPage, string searchText, SortByOptions sortBy)
        {
            var filters = new Filters <WebsiteViewData>();

            filters.Add(!string.IsNullOrEmpty(searchText), x => x.Name.Contains(searchText));

            var sorts = new Sorts <WebsiteViewData>();

            sorts.Add(sortBy == SortByOptions.Name, x => x.Name);
            sorts.Add(sortBy == SortByOptions.CreatedAt, x => x.CreatedAt);
            sorts.Add(sortBy == SortByOptions.EditedAt, x => x.EditedAt);

            return(await _dbContext.Websites
                   .Where(w => w.IsDeleted == false)
                   .Select(e => _mapper.Map(e))
                   .PaginateAsync(currentPage, pageSize, sorts, filters));
        }
Exemplo n.º 6
0
 /// <summary>
 /// 解析函数
 /// </summary>
 /// <param name="callExp"></param>
 /// <param name="funcName"></param>
 /// <param name="sortType"></param>
 private void ResolveSelectForFunc(MethodCallExpression callExp, string funcName, SortType sortType)
 {
     if (callExp.Arguments[0] is UnaryExpression unary && unary.Operand is LambdaExpression lambda)
     {
         var colName = GetColumnName(lambda.Body as MemberExpression, lambda);
         Sorts.Add(new Sort($"{funcName}({colName})", sortType));
     }
 }
Exemplo n.º 7
0
 public RequestData Sort(string fieldName, SortType sortType = SortType.Asc)
 {
     if (Sorts == null)
     {
         Sorts = new Dictionary <string, SortType>();
     }
     Sorts.Add(fieldName, sortType);
     return(this);
 }
Exemplo n.º 8
0
        public Page <Movie> GetPaginatedMovies(PagingModel pagingModel)
        {
            Page <Movie> movies;
            var          filters  = new Filters <Movie>();
            var          sortings = new Sorts <Movie>();

            sortings.Add(pagingModel.SortBy == 1, x => x.MovieId, pagingModel.IsDescending ?? false);
            sortings.Add(pagingModel.SortBy == 2, x => x.Name, pagingModel.IsDescending ?? false);
            sortings.Add(pagingModel.SortBy == 3, x => x.Ganre, pagingModel.IsDescending ?? false);

            filters.Add(pagingModel.SearchBy == 2 && !string.IsNullOrEmpty(pagingModel.SearchText),
                        x => x.Name.Contains(pagingModel.SearchText));
            filters.Add(pagingModel.SearchBy == 3 && !string.IsNullOrEmpty(pagingModel.SearchText),
                        x => x.Ganre.GenreName.Contains(pagingModel.SearchText));

            movies = _movieDbContext.Movies.Paginate(pagingModel.PageNumber, pagingModel.PageSize, sortings, filters);
            return(movies);
        }
Exemplo n.º 9
0
        public SearchyRequest(string queryString) : this()
        {
            var queryDictionary = QueryStringParser.Parse(queryString);

            if (queryDictionary.TryGetValue(FilterName, out var filters))
            {
                var cond = new SearchyCondition();
                Conditions.Add(cond);
                foreach (var str in filters)
                {
                    cond.Filters.Add(new SearchyFilter(str));
                }
            }

            if (queryDictionary.TryGetValue(SortName, out var sorts))
            {
                foreach (var str in sorts)
                {
                    Sorts.Add(new SearchySort(str));
                }
            }

            if (queryDictionary.TryGetValue(PageSizeName, out var sizes) &&
                sizes.Any() &&
                int.TryParse(sizes.First(), out var pageSize))
            {
                PageSize = pageSize;
            }

            if (queryDictionary.TryGetValue(PageIndexName, out var pages) &&
                pages.Any() &&
                int.TryParse(pages.First(), out var pageIndex))
            {
                PageIndex = pageIndex;
            }

            if (queryDictionary.TryGetValue(CountRowsName, out var counts) &&
                counts.Any() &&
                bool.TryParse(counts.First(), out var countRows))
            {
                CountRows = countRows;
            }

            if (queryDictionary.TryGetValue(SearchPhraseName, out var searches) &&
                searches.Any())
            {
                SearchPhrase = searches.First();
            }


            if (queryDictionary.TryGetValue(FormatName, out var formats) &&
                formats.Any() &&
                byte.TryParse(formats.First(), out var format))
            {
                Format = format;
            }
        }
Exemplo n.º 10
0
        public void SetOrderBy(Sort sort)
        {
            if (sort == null)
            {
                return;
            }

            Sorts.Add(sort);
        }
Exemplo n.º 11
0
        public async Task <Page <OfficeViewData> > GetPaginatedResultsAsync(
            int pageSize,
            int currentPage,
            string searchText,
            OfficeSearchOptions sortBy,
            OfficeSearchOptions searchBy)
        {
            var filters = new Filters <OfficeViewData>();

            switch (searchBy)
            {
            case OfficeSearchOptions.Country:
                filters.Add(!string.IsNullOrEmpty(searchText), x => x.Country.Contains(searchText));
                break;

            case OfficeSearchOptions.Street:
                filters.Add(!string.IsNullOrEmpty(searchText), x => x.Street.Contains(searchText));
                break;

            case OfficeSearchOptions.City:
            default:
                filters.Add(!string.IsNullOrEmpty(searchText), x => x.City.Contains(searchText));
                break;
            }

            var sorts = new Sorts <OfficeViewData>();

            sorts.Add(sortBy == OfficeSearchOptions.City, x => x.City);
            sorts.Add(sortBy == OfficeSearchOptions.Country, x => x.Country);
            sorts.Add(sortBy == OfficeSearchOptions.Street, x => x.Street);

            return(await _dbContext.Offices
                   .Select(o => new OfficeViewData
            {
                Id = o.Id,
                CompanyId = o.CompanyId,
                Country = o.Country,
                City = o.City,
                Street = o.Street,
                StreetNumber = o.StreetNumber,
                Employees = _dbContext.Employees.Where(e => e.OfficeId == o.Id).Count()
            })
                   .PaginateAsync(currentPage, pageSize, sorts, filters));
        }
Exemplo n.º 12
0
        public Page <Trek> GetFilteredPagedTreks(int pageSize, int currentPage, string countryName, int sortBy)
        {
            Page <Trek> treks;
            var         filters = new Filters <Trek>();

            filters.Add(!string.IsNullOrEmpty(countryName), x => x.Country.Equals(countryName));

            var sorts = new Sorts <Trek>();

            sorts.Add(sortBy == 1, x => x.DifficultyLevel);
            sorts.Add(sortBy == 2, x => x.DifficultyLevel, true);

            using (var context = new PlacesEntities())
            {
                treks = context.Treks.Paginate(currentPage, pageSize, sorts, filters);
            }

            return(treks);
        }
Exemplo n.º 13
0
        ///<inheritdoc/>
        IOrderQuery <SelectQuery> IWhereQuery <SelectQuery> .OrderBy(IOrder sort, params IOrder[] sorts)
        {
            Sorts.Add(sort);

            foreach (IOrder items in sorts.Where(s => Equals(s, default)))
            {
                Sorts.Add(sort);
            }
            return(this);
        }
Exemplo n.º 14
0
        public void FromStringToObject(string filtersname, string filtersvalue, string sortsname, string sortsvalue)
        {
            if (filtersname != "" && filtersname != null)
            {
                var FiltersName = new List <string>();
                try { FiltersName = filtersname.Split(';').ToList(); }
                catch (Exception e)
                {
                    FiltersName = new List <string>();
                }
                var FiltersValue = new List <string>();
                if (filtersvalue != null)
                {
                    try { FiltersValue = filtersvalue.Split(';').ToList(); }
                    catch (Exception e)
                    {
                        FiltersValue = new List <string>();
                    }
                }
                else
                {
                    FiltersValue = new List <string>();
                }

                for (int i = 0; i < FiltersName.Count; i++)
                {
                    if (i < FiltersValue.Count)
                    {
                        Filters.Add(new Filter()
                        {
                            name = FiltersName[i], value = FiltersValue[i]
                        });
                    }
                    else
                    {
                        Filters.Add(new Filter()
                        {
                            name = FiltersName[i], value = ""
                        });
                    }
                }
            }
            if (sortsname != "" && sortsvalue != "" && sortsname != null && sortsvalue != null)
            {
                var SortsName  = sortsname.Split(';').ToList();
                var SortsValue = sortsvalue.Split(';').ToList();
                for (int i = 0; i < SortsName.Count; i++)
                {
                    Sorts.Add(new Sort()
                    {
                        name = SortsName[i], value = SortsValue[i]
                    });
                }
            }
        }
        public Page <Employee> GetFilteredEmployees(int pageSize, int currentPage, string searchText, int sortBy, string jobTitle)
        {
            Page <Employee> employees;
            var             filters = new Filters <Employee>();
            var             sorts   = new Sorts <Employee>();

            filters.Add(!string.IsNullOrEmpty(searchText), x => x.LoginID.Contains(searchText));
            filters.Add(!string.IsNullOrEmpty(jobTitle), x => x.JobTitle.Equals(jobTitle));

            sorts.Add(sortBy == 1, x => x.BusinessEntityID);
            sorts.Add(sortBy == 2, x => x.LoginID);
            sorts.Add(sortBy == 3, x => x.JobTitle);

            using (var context = new AdventureWorksEntities())
            {
                employees = context.Employees.Paginate(currentPage, pageSize, sorts, filters);
            }

            return(employees);
        }
Exemplo n.º 16
0
 //TODO instancier chaque sort
 // Start is called before the first frame update
 void Start()
 {
     if (algo == null)
     {
         algo = GetComponent <AlgoDeplacement>();
     }
     foreach (GameObject g in sortsG)
     {
         g.GetComponent <Sort>().Detenteur = this;
         Sorts.Add(g.GetComponent <Sort>());
     }
 }
Exemplo n.º 17
0
        public void SetOrderBy(LambdaExpression expression, SortType sortType = SortType.Asc)
        {
            if (expression == null)
            {
                return;
            }

            if (expression == null || !(expression.Body is MemberExpression memberExpression) || memberExpression.Expression.NodeType != ExpressionType.Parameter)
            {
                throw new ArgumentException("排序列无效");
            }

            Sorts.Add(new Sort(GetColumnName(memberExpression), sortType));
        }
Exemplo n.º 18
0
        public static Page <Car> GetCars(CarFilter f)
        {
            Page <Car> list;
            var        filters = new Filters <Car>();
            var        sorts   = new Sorts <Car>();

            filters.Add(f.Caption != null && f.Caption.Count > 0, car => f.Caption.Contains(car.Caption));
            filters.Add(f.Price != null && f.Price.Count == 2, car => car.Price >= f.Price[0] && car.Price <= f.Price[1]);
            filters.Add(f.Make != null && f.Make.Count > 0, car => f.Make.Contains(car.Make));
            filters.Add(f.Model != null && f.Model.Count > 0, car => f.Model.Contains(car.Model));
            filters.Add(f.Year != null && f.Year.Count == 2, car => car.Price >= f.Year[0] && car.Price <= f.Year[1]);
            filters.Add(f.Month != null && f.Month.Count > 0, car => f.Month.Contains(car.Month));
            filters.Add(f.Mileage != null && f.Mileage.Count == 2, car => car.Mileage >= f.Mileage[0] && car.Mileage <= f.Mileage[1]);
            filters.Add(f.Transmission != null && f.Transmission.Count > 0, car => f.Transmission.Contains(car.Transmission));
            filters.Add(f.Location != null && f.Location.Count > 0, car => f.Location.Contains(car.Location));
            filters.Add(f.StockId != null && f.StockId.Count > 0, car => f.StockId.Contains(car.StockId));
            filters.Add(f.ChassisNo != null && f.ChassisNo.Count > 0, car => f.ChassisNo.Contains(car.ChassisNo));
            filters.Add(f.Displacement != null && f.Displacement.Count == 2, car => car.Displacement >= f.Displacement[0] && car.Displacement <= f.Displacement[1]);
            filters.Add(f.Steering != null && f.Steering.Count > 0, car => f.Steering.Contains(car.Steering));
            filters.Add(f.FuelType != null && f.FuelType.Count > 0, car => f.FuelType.Contains(car.FuelType));
            filters.Add(f.Door != null && f.Door.Count > 0, car => f.Door.Contains(car.Door));
            filters.Add(f.Grade != null && f.Grade.Count > 0, car => f.Grade.Contains(car.Grade));
            filters.Add(f.Featured != null && f.Featured.Count > 0, car => f.Featured.Contains(car.Featured));

            sorts.Add(f.SortBy == (int)SortBy.PriceLowest, car => car.Price, false);
            sorts.Add(f.SortBy == (int)SortBy.PriceHighest, car => car.Price, true);
            sorts.Add(f.SortBy == (int)SortBy.MileageLowest, car => car.Mileage, false);
            sorts.Add(f.SortBy == (int)SortBy.MileageHighest, car => car.Mileage, true);

            using (var context = new CarDbContext())
            {
                list = context.Cars.Paginate(f.CurrentPage, f.PageSize, sorts, filters);
            }

            return(list);
        }
Exemplo n.º 19
0
        public void SetOrderBy(Sort sort)
        {
            if (sort == null)
            {
                return;
            }

            foreach (var des in JoinDescriptors)
            {
                foreach (var column in des.EntityDescriptor.Columns)
                {
                    if (column.Name.Equals(sort.OrderBy, StringComparison.OrdinalIgnoreCase) ||
                        column.PropertyInfo.Name.Equals(sort.OrderBy, StringComparison.OrdinalIgnoreCase))
                    {
                        Sorts.Add(sort);
                        break;
                    }
                }
            }
        }
Exemplo n.º 20
0
        public async Task <Page <CompanyViewData> > GetPaginatedResultsAsync(int pageSize, int currentPage, string searchText, CompanySearchOptions sortBy)
        {
            var filters = new Filters <CompanyViewData>();

            filters.Add(!string.IsNullOrEmpty(searchText), x => x.Name.Contains(searchText));

            var sorts = new Sorts <CompanyViewData>();

            sorts.Add(sortBy == CompanySearchOptions.Name, x => x.Name);

            return(await _dbContext.Companies
                   .Select(e => new CompanyViewData
            {
                Id = e.Id,
                Name = e.Name,
                CreatedAt = e.CreatedAt,
                OfficesAmount = e.Offices.Where(o => o.CompanyId == e.Id).Count()
            })
                   .PaginateAsync(currentPage, pageSize, sorts, filters));
        }
Exemplo n.º 21
0
 private void SetOrderByForSubstring(MethodCallExpression callExp, LambdaExpression fullExpression, SortType sortType)
 {
     if (callExp.Object is MemberExpression objExp && objExp.Expression.NodeType == ExpressionType.Parameter)
     {
         var funcName = _sqlAdapter.FuncSubstring;
         var colName  = GetColumnName(objExp, fullExpression);
         var start    = ((ConstantExpression)callExp.Arguments[0]).Value.ToInt() + 1;
         if (callExp.Arguments.Count > 1 || _sqlAdapter.SqlDialect != SqlDialect.SqlServer)
         {
             var length = ((ConstantExpression)callExp.Arguments[1]).Value.ToInt();
             var name   = $"{funcName}({colName},{start},{length})";
             Sorts.Add(new Sort(name, sortType));
         }
         else
         {
             var name = $"{funcName}({colName},{start})";
             Sorts.Add(new Sort(name, sortType));
         }
     }
 }
Exemplo n.º 22
0
        private void SetOrderByMethod(LambdaExpression expression, MethodCallExpression methodCallExp, SortType sortType = SortType.Asc)
        {
            var methodName = methodCallExp.Method.Name;

            if (methodName.Equals("Substring"))
            {
                SetOrderByForSubstring(methodCallExp, expression, sortType);
                return;
            }

            if (methodName.Equals("Count"))
            {
                Sorts.Add(new Sort("COUNT(0)", sortType));
                return;
            }

            if (methodName.Equals("Sum"))
            {
                ResolveSelectForFunc(methodCallExp, "SUM");
                return;
            }

            if (methodName.Equals("Avg"))
            {
                ResolveSelectForFunc(methodCallExp, "AVG");
                return;
            }

            if (methodName.Equals("Max"))
            {
                ResolveSelectForFunc(methodCallExp, "MAX");
                return;
            }

            if (methodName.Equals("Min"))
            {
                ResolveSelectForFunc(methodCallExp, "MIN");
            }
        }
Exemplo n.º 23
0
        private void SetOrderByMethod(LambdaExpression expression, MethodCallExpression methodCallExp, SortType sortType = SortType.Asc)
        {
            var methodName = methodCallExp.Method.Name.ToUpper();

            switch (methodName)
            {
            case "SUBSTRING":
                SetOrderByForSubstring(methodCallExp, expression, sortType);
                return;

            case "COUNT":
                Sorts.Add(new Sort("COUNT(0)", sortType));
                return;

            case "SUM":
            case "AVG":
            case "MAX":
            case "MIN":
                ResolveSelectForFunc(methodCallExp, methodName, sortType);
                return;
            }
        }
Exemplo n.º 24
0
        public SearchyRequest(string[] filters, string[] sorts = null, int pageSize = 0, int pageIndex = 0, bool countRows = false) : this()
        {
            if (filters != null)
            {
                var cond = new SearchyCondition();
                Conditions.Add(cond);
                foreach (var str in filters)
                {
                    cond.Filters.Add(new SearchyFilter(str));
                }
            }

            if (sorts != null)
            {
                foreach (var str in sorts)
                {
                    Sorts.Add(new SearchySort(str));
                }
            }

            PageSize  = pageSize;
            PageIndex = pageIndex;
            CountRows = countRows;
        }
Exemplo n.º 25
0
        public JsonResult GetCategoriesDataTable(JQueryDataTableParamModel param)
        {
            var oCategory = new Category();

            if (!string.IsNullOrEmpty(Request.QueryString["Id"]))
            {
                oCategory.Id = Convert.ToInt32(Request.QueryString["Id"]);
            }

            DataTableProcessModel m         = new DataTableProcessModel();
            DataTableProcessModel dtProcess = DataTableProcesses.DataTableEslestir(param, m);
            //oCategory.SortCol = dtProcess.SortCol;
            //oCategory.SortType = dtProcess.SortType;
            //oCategory.Page = dtProcess.Page;
            //oCategory.RowPerPage = dtProcess.RowPerPage;
            //oCategory.IsList = true;

            //var getCategory = DAL.News.News.CategoryGet(oCategory);

            var filters = new Filters <Category>();

            filters.Add(oCategory.Id > 0, x => x.Id == oCategory.Id);
            filters.Add(true, x => x.IsDeleted == false);
            filters.Add(true, x => x.Id > 1);

            var sorts = new Sorts <Category>();

            sorts.Add(dtProcess.SortCol == "Id", x => x.Id);

            var getCategory = _db.Categories.Paginate(dtProcess.Page, 100, sorts, filters);


            if (getCategory.RecordCount > 0)
            {
                var getCategoryResult = getCategory.Results;

                int rowCount   = getCategory.RecordCount;
                int lnRowCount = rowCount;

                var result = from q in getCategoryResult
                             select new
                {
                    q.Id,
                    q.NameAr,
                    q.NameEn
                };

                return(Json(new
                {
                    param.sEcho,
                    iTotalRecords = rowCount,
                    iTotalDisplayRecords = lnRowCount,
                    aaData = result
                },
                            JsonRequestBehavior.AllowGet));
            }
            else
            {
                int rowCount   = getCategory.RecordCount;
                int lnRowCount = rowCount;

                var result = from q in getCategory.Results
                             select new
                {
                    q.Id,
                    q.NameAr,
                    q.NameEn
                };

                return(Json(new
                {
                    param.sEcho,
                    iTotalRecords = rowCount,
                    iTotalDisplayRecords = lnRowCount,
                    aaData = result
                },
                            JsonRequestBehavior.AllowGet));
            }
        }
Exemplo n.º 26
0
 public FindOptions <TRecord> SortDescending(Expression <Func <TRecord, long> > field)
 {
     Sorts.Add(field, SortDirection.Descending);
     return(this);
 }
Exemplo n.º 27
0
 public FindOptions <TRecord> SortAscending(Expression <Func <TRecord, DateTime> > field)
 {
     Sorts.Add(field, SortDirection.Ascending);
     return(this);
 }
Exemplo n.º 28
0
        public JsonResult GetNewsDataTable(JQueryDataTableParamModel param)
        {
            var oNews = new News();

            if (!string.IsNullOrEmpty(Request.QueryString["NewsSearch"]))
            {
                oNews.Title = Request.QueryString["NewsSearch"];
            }
            if (!string.IsNullOrEmpty(Request.QueryString["Category"]))
            {
                oNews.CategoryId = Convert.ToInt32(Request.QueryString["Category"]);
            }
            if (!string.IsNullOrEmpty(Request.QueryString["InsertedBy"]))
            {
                oNews.InsertedBy = Convert.ToInt32(Request.QueryString["InsertedBy"]);
            }

            CultureInfo newCulture = (CultureInfo)Thread.CurrentThread.CurrentCulture.Clone();

            newCulture.DateTimeFormat.ShortDatePattern = "dd-MM-yyyy";
            newCulture.DateTimeFormat.DateSeparator    = "-";
            Thread.CurrentThread.CurrentCulture        = newCulture;
            if (!string.IsNullOrEmpty(Request.QueryString["FromDate"]))
            {
                string date = Request.QueryString["FromDate"];
                oNews.FromDate = CommonHelpExtension.ConvertToUTC(Convert.ToDateTime(date, newCulture));
            }
            if (!string.IsNullOrEmpty(Request.QueryString["ToDate"]))
            {
                string date = Request.QueryString["ToDate"];
                oNews.ToDate = CommonHelpExtension.ConvertToUTC(Convert.ToDateTime(date, newCulture));
            }
            DataTableProcessModel m         = new DataTableProcessModel();
            DataTableProcessModel dtProcess = DataTableProcesses.DataTableEslestir(param, m);
            //oNews.SortCol = dtProcess.SortCol;
            //oNews.SortType = dtProcess.SortType;
            //oNews.Page = dtProcess.Page;
            //oNews.RowPerPage = dtProcess.RowPerPage;

            //var getNews = DAL.News.News.NewsGet(oNews, 0);

            var filters = new Filters <News>();

            filters.Add(oNews.Id > 0, x => x.Id == oNews.Id);
            filters.Add(oNews.FromDate != new DateTime() && oNews.FromDate != null, x => x.PublishDate >= oNews.FromDate);
            filters.Add(oNews.ToDate != new DateTime() && oNews.ToDate != null, x => x.PublishDate <= oNews.ToDate);
            filters.Add(!string.IsNullOrEmpty(oNews.Title), x => x.Title.Contains(oNews.Title));
            filters.Add(true, x => x.IsDeleted == false);
            filters.Add(true, x => x.CategoryId == 1);

            var sorts = new Sorts <News>();

            sorts.Add(dtProcess.SortCol == "Id", x => x.Id);
            sorts.Add(dtProcess.SortCol == "Title", x => x.Title);
            sorts.Add(dtProcess.SortCol == "PublishDate", x => x.PublishDate);

            var getNews = _db.News.Paginate(dtProcess.Page, dtProcess.RowPerPage, sorts, filters);

            if (getNews.RecordCount > 0)
            {
                var getNewsResult = getNews.Results;

                int rowCount   = getNews.RecordCount;
                int lnRowCount = rowCount;

                var result = from q in getNewsResult
                             select new
                {
                    q.Id,
                    q.IsActive,
                    q.CategoryId,
                    q.Image,
                    q.Status,
                    q.Title,
                    q.ViewsCount,
                    q.InsertedBy,
                    PublishDate    = q.PublishDate.ToString("yyyy-MM-dd HH:mm:ss"),
                    InsertedByName = q.UserAccount.Name,
                    q.Category.NameAr,
                    q.Category.NameEn,
                };

                return(Json(new
                {
                    param.sEcho,
                    iTotalRecords = rowCount,
                    iTotalDisplayRecords = lnRowCount,
                    aaData = result
                },
                            JsonRequestBehavior.AllowGet));
            }
            else
            {
                int rowCount   = getNews.RecordCount;
                int lnRowCount = rowCount;

                var result = from q in getNews.Results
                             select new
                {
                    q.Id,
                    q.IsActive,
                    q.CategoryId,
                    q.Image,
                    q.Status,
                    q.Title,
                    q.ViewsCount,
                    q.InsertedBy,
                    PublishDate = q.PublishDate.ToString("yyyy-MM-dd HH:mm:ss"),
                    q.UserAccount.Name,
                    q.Category.NameAr,
                    q.Category.NameEn,
                };

                return(Json(new
                {
                    param.sEcho,
                    iTotalRecords = rowCount,
                    iTotalDisplayRecords = lnRowCount,
                    aaData = result
                },
                            JsonRequestBehavior.AllowGet));
            }
        }
Exemplo n.º 29
0
 public void AddSort(string sort)
 {
     Sorts.Add(sort);
 }
Exemplo n.º 30
0
        public JsonResult GetStaticPagesDataTable(JQueryDataTableParamModel param)
        {
            var oStaticPage = new StaticPage();

            if (!string.IsNullOrEmpty(Request.QueryString["Id"]))
            {
                oStaticPage.Id = Convert.ToInt32(Request.QueryString["Id"]);
            }

            DataTableProcessModel m         = new DataTableProcessModel();
            DataTableProcessModel dtProcess = DataTableProcesses.DataTableEslestir(param, m);
            //oStaticPage.SortCol = dtProcess.SortCol;
            //oStaticPage.SortType = dtProcess.SortType;
            //oStaticPage.Page = dtProcess.Page;
            //oStaticPage.RowPerPage = dtProcess.RowPerPage;

            //var getStaticPage = DAL.News.StaticPages.StaticPagesGet(oStaticPage);

            //var filters = new Filters<StaticPage>();
            //filters.Add(Convert.ToBoolean(oUserType.Name), x => x.Name == oUserType.Name);
            //filters.Add(true, x => x.IsDeleted == false);

            var sorts = new Sorts <StaticPage>();

            sorts.Add(dtProcess.SortCol == "Id", x => x.Id);

            var getStaticPage = _db.StaticPages.Paginate(dtProcess.Page, dtProcess.RowPerPage, sorts);

            if (getStaticPage.RecordCount > 0)
            {
                var getStaticPageResult = getStaticPage.Results;

                int rowCount   = getStaticPage.RecordCount;
                int lnRowCount = rowCount;

                var result = from q in getStaticPageResult
                             select new
                {
                    q.Id,
                    q.Image,
                    q.PageName
                };
                return(Json(new
                {
                    param.sEcho,
                    iTotalRecords = rowCount,
                    iTotalDisplayRecords = lnRowCount,
                    aaData = result
                },
                            JsonRequestBehavior.AllowGet));
            }
            else
            {
                int rowCount   = getStaticPage.RecordCount;
                int lnRowCount = rowCount;

                var result = from q in getStaticPage.Results
                             select new
                {
                    q.Id,
                    q.Image,
                    q.PageName
                };

                return(Json(new
                {
                    param.sEcho,
                    iTotalRecords = rowCount,
                    iTotalDisplayRecords = lnRowCount,
                    aaData = result
                },
                            JsonRequestBehavior.AllowGet));
            }
        }