예제 #1
0
        private IQueryable <IJPDetail> SearchAssets(IDataTablesRequest requestModel, AdvancdedSearchModel searchViewModel, IQueryable <IJPDetail> query)
        {
            // Apply filters
            if (requestModel.Search.Value != string.Empty)
            {
                var value = requestModel.Search.Value.Trim();
                query = query.Where(p => p.Job.Contains(value)
                                    //p.Experience.Contains(value) ||
                                    //p.LastDate.Contains(value) ||
                                    //p.ApplicationReceived.Contains(value)
                                    );
            }


            /***** Advanced Search ******/
            if (searchViewModel.StatusId != 0)
            {
                query = query.Where(x => x.StatusId == searchViewModel.StatusId);
            }

            if (searchViewModel.Job != null)
            {
                query = query.Where(x => x.Job == searchViewModel.Job);
            }

            /***** Advanced Search ******/

            var filteredCount = query.Count();

            // Sort
            var sortedColumns = requestModel.Columns.GetSortedColumns();
            var orderByString = String.Empty;

            foreach (var column in sortedColumns)
            {
                orderByString += orderByString != String.Empty ? "," : "";
                orderByString += (column.Data) + (column.SortDirection == Column.OrderDirection.Ascendant ? " asc" : " desc");
            }

            //query = query.OrderBy(orderByString == string.Empty ? "BarCode asc" : orderByString);

            return(query);
        }
예제 #2
0
        public ActionResult AdvancedSearch()
        {
            var advancedSearchViewModel = new AdvancdedSearchModel();

            advancedSearchViewModel.StatusList = new SelectList(DbContext.Status
                                                                .Select(x => new { x.Id, x.Status1 }),
                                                                "Id",
                                                                "Status1");



            advancedSearchViewModel.JobList = new SelectList(DbContext.IJPDetails
                                                             .GroupBy(x => x.Job)
                                                             .Where(x => x.Key != null && !x.Key.Equals(string.Empty))
                                                             .Select(x => new { Job = x.Key }),
                                                             "Job",
                                                             "Job");


            return(View("_AdvancedSearchPartial", advancedSearchViewModel));
        }
예제 #3
0
        public ActionResult Get([ModelBinder(typeof(DataTablesBinder))] IDataTablesRequest requestModel, AdvancdedSearchModel searchViewModel)
        {
            IQueryable <IJPDetail> query = DbContext.IJPDetails;
            var totalCount = query.Count();

            // searching and sorting
            query = SearchAssets(requestModel, searchViewModel, query);
            var filteredCount = query.Count();



            // Paging
            query = query.OrderBy(m => m.Id).Skip(requestModel.Start).Take(requestModel.Length);



            var data = query.Select(IJP => new
            {
                Id                  = IJP.Id,
                Job                 = IJP.Job,
                Experience          = IJP.Experience,
                LastDate            = IJP.LastDate,
                ApplicationReceived = IJP.ApplicationReceived,
                Quantity            = IJP.Quantity,
            }).ToList();


            return(Json(new DataTablesResponse(requestModel.Draw, data, filteredCount, totalCount), JsonRequestBehavior.AllowGet));
        }