예제 #1
0
        /// <summary>
        /// This method returns the view data for the Worker Signin class.
        /// </summary>
        /// <param name="o">View options from DataTables</param>
        /// <returns>dataTableResult WorkerSigninList</returns>
        public dataTableResult <DTO.WorkerSigninList> GetIndexView(viewOptions o)
        {
            var result = new dataTableResult <DTO.WorkerSigninList>();
            IQueryable <WorkerSignin> q = GetAll();

            var unused = q.Count();

            if (o.date != null)
            {
                var requestedDate = o.date.Value.DateBasedOn(ClientTimeZoneInfo); // 12:00:00 AM client time
                var endOfDay      = requestedDate.AddDays(1).AddMilliseconds(-1);

                var qDates = q.Select(the => new { the.ID, the.dateforsignin }).ToList();

                var qIDs = qDates.Where(the =>
                                        the.dateforsignin.DateTimeFrom(ClientTimeZoneInfo) >= requestedDate &&
                                        the.dateforsignin.DateTimeFrom(ClientTimeZoneInfo) <= endOfDay)
                           .Select(the => the.ID);

                q = q.Where(wsi => qIDs.Contains(wsi.ID));
                var blah = q.Count();
            }

            if (o.typeofwork_grouping != null)
            {
                IndexViewBase.typeOfWork(o, ref q);
            }
            IndexViewBase.waGrouping(o, ref q, db.WorkerRequests.AsNoTracking().AsQueryable());
            if (o.dwccardnum > 0)
            {
                IndexViewBase.dwccardnum(o, ref q);
            }
            if (!string.IsNullOrEmpty(o.sSearch))
            {
                IndexViewBase.search(o, ref q);
            }

            IndexViewBase.sortOnColName(o.sortColName, o.orderDescending, ref q);
            result.filteredCount = q.Count();
            result.totalCount    = GetAll().Count();
            if (o.displayLength > 0)
            {
                result.query = q.ProjectTo <DTO.WorkerSigninList>(map.ConfigurationProvider)
                               .Skip(o.displayStart)
                               .Take(o.displayLength)
                               .AsEnumerable();
            }
            else
            {
                result.query = q.ProjectTo <DTO.WorkerSigninList>(map.ConfigurationProvider)
                               .AsEnumerable();
            }
            return(result);
        }
예제 #2
0
        /// <summary>
        /// This method returns the view data for the Worker Signin class.
        /// </summary>
        /// <param name="o">View options from DataTables</param>
        /// <returns>dataTableResult WorkerSigninList</returns>
        public dataTableResult <DTO.WorkerSigninList> GetIndexView(viewOptions o)
        {
            //
            var result = new dataTableResult <DTO.WorkerSigninList>();
            IQueryable <Domain.WorkerSignin> q = repo.GetAllQ();

            //
            if (o.date != null)
            {
                IndexViewBase.diffDays(o, ref q);
            }
            if (o.typeofwork_grouping != null)
            {
                IndexViewBase.typeOfWork(o, ref q);
            }
            IndexViewBase.waGrouping(o, ref q, wrServ);
            if (o.dwccardnum > 0)
            {
                IndexViewBase.dwccardnum(o, ref q);
            }
            if (!string.IsNullOrEmpty(o.sSearch))
            {
                IndexViewBase.search(o, ref q);
            }

            IndexViewBase.sortOnColName(o.sortColName, o.orderDescending, ref q);
            result.filteredCount = q.Count();
            result.totalCount    = repo.GetAllQ().Count();
            if (o.displayLength > 0)
            {
                result.query = q.ProjectTo <DTO.WorkerSigninList>(map.ConfigurationProvider)
                               .Skip(o.displayStart)
                               .Take(o.displayLength)
                               .AsEnumerable();
            }
            else
            {
                result.query = q.ProjectTo <DTO.WorkerSigninList>(map.ConfigurationProvider)
                               .AsEnumerable();
            }
            return(result);
        }