예제 #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="o"></param>
        /// <returns></returns>
        public dataTableResult <DTO.ActivitySigninList> GetIndexView(viewOptions o)
        {
            var result = new dataTableResult <DTO.ActivitySigninList>();
            IQueryable <ActivitySignin> q = repo.GetAllQ();

            //
            if (o.date != null)
            {
                // good intentions marinated in panic
                q = q.Where(p =>
                            p.dateforsignin.DateBasedOn(ClientTimeZoneInfo) == o.date.Value.DateBasedOn(ClientTimeZoneInfo)
                            );
            }

            if (o.personID > 0)
            {
                IndexViewBase.GetAssociated(o.personID, ref q);
            }
            if (o.activityID != null)
            {
                q = q.Where(p => p.activityID == o.activityID);
            }
            //
            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.ActivitySigninList>(map.ConfigurationProvider)
                               .Skip(o.displayStart)
                               .Take(o.displayLength)
                               .AsEnumerable();
            }
            else
            {
                result.query = q.ProjectTo <DTO.ActivitySigninList>(map.ConfigurationProvider)
                               .AsEnumerable();
            }
            return(result);
        }