Пример #1
0
        public dataTableResult <DTO.WorkAssignmentsList> GetIndexView(viewOptions o)
        {
            var result = new dataTableResult <DTO.WorkAssignmentsList>();
            IQueryable <WorkAssignment> q = waRepo.GetAllQ();

            //
            //
            if (o.date != null)
            {
                IndexViewBase.diffDays((DateTime)o.date, ref q);
            }
            if (o.typeofwork_grouping > 0)
            {
                IndexViewBase.typeOfWork(o, ref q, lRepo);
            }
            if (o.woid > 0)
            {
                IndexViewBase.WOID(o, ref q);
            }
            if (o.personID > 0)
            {
                IndexViewBase.WID(o, ref q);
            }
            if (o.status > 0)
            {
                IndexViewBase.status(o, ref q);
            }
            if (o.showPending == false)
            {
                IndexViewBase.filterPending(o, ref q);
            }
            if (!string.IsNullOrEmpty(o.wa_grouping))
            {
                IndexViewBase.waGrouping(o, ref q, lRepo);
            }
            if (!string.IsNullOrEmpty(o.sSearch))
            {
                IndexViewBase.search(o, ref q, lRepo);
            }
            if (o.dwccardnum > 0)
            {
                var worker = wRepo.GetById((int)o.dwccardnum);
                IndexViewBase.filterOnSkill(o, q, lRepo, worker);
            }
            //Sort the Persons based on column selection
            IndexViewBase.sortOnColName(o.sortColName, o.orderDescending, ref q);
            //e = e.ToList();
            result.filteredCount = q.Count();
            if (o.displayLength > 0)
            {
                result.query = q.ProjectTo <DTO.WorkAssignmentsList>(map.ConfigurationProvider)
                               .Skip(o.displayStart)
                               .Take(o.displayLength)
                               .AsEnumerable();
            }
            else
            {
                result.query = q.ProjectTo <DTO.WorkAssignmentsList>(map.ConfigurationProvider)
                               .AsEnumerable();
            }
            result.totalCount = waRepo.GetAllQ().Count();
            return(result);
        }