Exemplo n.º 1
0
        public void Delete(IntervalSearch request)
        {
            var matches = Get(request) as List <Interval>;

            if (true != matches?.Any())
            {
                throw new HttpError(HttpStatusCode.NotFound, "No matches for request");
            }
            matches.ForEach(match =>
            {
                Delete(match);
            });
        }
Exemplo n.º 2
0
 public object Get(IntervalSearch request) => GetSearchResultWithCache <Interval, DocEntityInterval, IntervalSearch>(DocConstantModelName.INTERVAL, request, _ExecSearch);
Exemplo n.º 3
0
        private IQueryable <DocEntityInterval> _ExecSearch(IntervalSearch request, DocQuery query)
        {
            request = InitSearch <Interval, IntervalSearch>(request);
            IQueryable <DocEntityInterval> entities = null;

            query.Run(session =>
            {
                entities = query.SelectAll <DocEntityInterval>();
                if (!DocTools.IsNullOrEmpty(request.FullTextSearch))
                {
                    var fts  = new IntervalFullTextSearch(request);
                    entities = GetFullTextSearch <DocEntityInterval, IntervalFullTextSearch>(fts, entities);
                }

                if (null != request.Ids && request.Ids.Any())
                {
                    entities = entities.Where(en => en.Id.In(request.Ids));
                }

                if (!DocTools.IsNullOrEmpty(request.Updated))
                {
                    entities = entities.Where(e => null != e.Updated && e.Updated.Value.Date == request.Updated.Value.Date);
                }
                if (!DocTools.IsNullOrEmpty(request.UpdatedBefore))
                {
                    entities = entities.Where(e => null != e.Updated && e.Updated <= request.UpdatedBefore);
                }
                if (!DocTools.IsNullOrEmpty(request.UpdatedAfter))
                {
                    entities = entities.Where(e => null != e.Updated && e.Updated >= request.UpdatedAfter);
                }
                if (!DocTools.IsNullOrEmpty(request.Created))
                {
                    entities = entities.Where(e => null != e.Created && e.Created.Value.Date == request.Created.Value.Date);
                }
                if (!DocTools.IsNullOrEmpty(request.CreatedBefore))
                {
                    entities = entities.Where(e => null != e.Created && e.Created <= request.CreatedBefore);
                }
                if (!DocTools.IsNullOrEmpty(request.CreatedAfter))
                {
                    entities = entities.Where(e => null != e.Created && e.Created >= request.CreatedAfter);
                }
                if (true == request.Archived?.Any() && currentUser.HasProperty(DocConstantModelName.INTERVAL, nameof(Reference.Archived), DocConstantPermission.VIEW))
                {
                    entities = entities.Where(en => en.Archived.In(request.Archived));
                }
                else
                {
                    entities = entities.Where(en => !en.Archived);
                }
                if (true == request.Locked?.Any())
                {
                    entities = entities.Where(en => en.Locked.In(request.Locked));
                }
                if (!DocTools.IsNullOrEmpty(request.CalendarDateEnd) && !DocTools.IsNullOrEmpty(request.CalendarDateEnd.Id))
                {
                    entities = entities.Where(en => en.CalendarDateEnd.Id == request.CalendarDateEnd.Id);
                }
                if (true == request.CalendarDateEndIds?.Any())
                {
                    entities = entities.Where(en => en.CalendarDateEnd.Id.In(request.CalendarDateEndIds));
                }
                if (!DocTools.IsNullOrEmpty(request.CalendarDateStart) && !DocTools.IsNullOrEmpty(request.CalendarDateStart.Id))
                {
                    entities = entities.Where(en => en.CalendarDateStart.Id == request.CalendarDateStart.Id);
                }
                if (true == request.CalendarDateStartIds?.Any())
                {
                    entities = entities.Where(en => en.CalendarDateStart.Id.In(request.CalendarDateStartIds));
                }
                if (!DocTools.IsNullOrEmpty(request.CalendarType))
                {
                    entities = entities.Where(en => en.CalendarType.Contains(request.CalendarType));
                }
                if (!DocTools.IsNullOrEmpty(request.CalendarTypes))
                {
                    entities = entities.Where(en => en.CalendarType.In(request.CalendarTypes));
                }
                if (!DocTools.IsNullOrEmpty(request.FollowUp) && !DocTools.IsNullOrEmpty(request.FollowUp.Id))
                {
                    entities = entities.Where(en => en.FollowUp.Id == request.FollowUp.Id);
                }
                if (true == request.FollowUpIds?.Any())
                {
                    entities = entities.Where(en => en.FollowUp.Id.In(request.FollowUpIds));
                }
                if (!DocTools.IsNullOrEmpty(request.TimeOfDay) && !DocTools.IsNullOrEmpty(request.TimeOfDay.Id))
                {
                    entities = entities.Where(en => en.TimeOfDay.Id == request.TimeOfDay.Id);
                }
                if (true == request.TimeOfDayIds?.Any())
                {
                    entities = entities.Where(en => en.TimeOfDay.Id.In(request.TimeOfDayIds));
                }

                entities = ApplyFilters <DocEntityInterval, IntervalSearch>(request, entities);

                if (request.Skip > 0)
                {
                    entities = entities.Skip(request.Skip.Value);
                }
                if (request.Take > 0)
                {
                    entities = entities.Take(request.Take.Value);
                }
                if (true == request?.OrderBy?.Any())
                {
                    entities = entities.OrderBy(request.OrderBy);
                }
                if (true == request?.OrderByDesc?.Any())
                {
                    entities = entities.OrderByDescending(request.OrderByDesc);
                }
            });
            return(entities);
        }
Exemplo n.º 4
0
 public object Post(IntervalSearch request) => Get(request);