Beispiel #1
0
        public void Delete(UserTypeSearch request)
        {
            var matches = Get(request) as List <UserType>;

            if (true != matches?.Any())
            {
                throw new HttpError(HttpStatusCode.NotFound, "No matches for request");
            }
            matches.ForEach(match =>
            {
                Delete(match);
            });
        }
Beispiel #2
0
 public object Get(UserTypeSearch request) => GetSearchResultWithCache <UserType, DocEntityUserType, UserTypeSearch>(DocConstantModelName.USERTYPE, request, _ExecSearch);
Beispiel #3
0
        private IQueryable <DocEntityUserType> _ExecSearch(UserTypeSearch request, DocQuery query)
        {
            request = InitSearch <UserType, UserTypeSearch>(request);
            IQueryable <DocEntityUserType> entities = null;

            query.Run(session =>
            {
                entities = query.SelectAll <DocEntityUserType>();
                if (!DocTools.IsNullOrEmpty(request.FullTextSearch))
                {
                    var fts  = new UserTypeFullTextSearch(request);
                    entities = GetFullTextSearch <DocEntityUserType, UserTypeFullTextSearch>(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.USERTYPE, 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.PayrollStatus) && !DocTools.IsNullOrEmpty(request.PayrollStatus.Id))
                {
                    entities = entities.Where(en => en.PayrollStatus.Id == request.PayrollStatus.Id);
                }
                if (true == request.PayrollStatusIds?.Any())
                {
                    entities = entities.Where(en => en.PayrollStatus.Id.In(request.PayrollStatusIds));
                }
                else if (!DocTools.IsNullOrEmpty(request.PayrollStatus) && !DocTools.IsNullOrEmpty(request.PayrollStatus.Name))
                {
                    entities = entities.Where(en => en.PayrollStatus.Name == request.PayrollStatus.Name);
                }
                if (true == request.PayrollStatusNames?.Any())
                {
                    entities = entities.Where(en => en.PayrollStatus.Name.In(request.PayrollStatusNames));
                }
                if (!DocTools.IsNullOrEmpty(request.PayrollType) && !DocTools.IsNullOrEmpty(request.PayrollType.Id))
                {
                    entities = entities.Where(en => en.PayrollType.Id == request.PayrollType.Id);
                }
                if (true == request.PayrollTypeIds?.Any())
                {
                    entities = entities.Where(en => en.PayrollType.Id.In(request.PayrollTypeIds));
                }
                else if (!DocTools.IsNullOrEmpty(request.PayrollType) && !DocTools.IsNullOrEmpty(request.PayrollType.Name))
                {
                    entities = entities.Where(en => en.PayrollType.Name == request.PayrollType.Name);
                }
                if (true == request.PayrollTypeNames?.Any())
                {
                    entities = entities.Where(en => en.PayrollType.Name.In(request.PayrollTypeNames));
                }
                if (!DocTools.IsNullOrEmpty(request.Type) && !DocTools.IsNullOrEmpty(request.Type.Id))
                {
                    entities = entities.Where(en => en.Type.Id == request.Type.Id);
                }
                if (true == request.TypeIds?.Any())
                {
                    entities = entities.Where(en => en.Type.Id.In(request.TypeIds));
                }
                else if (!DocTools.IsNullOrEmpty(request.Type) && !DocTools.IsNullOrEmpty(request.Type.Name))
                {
                    entities = entities.Where(en => en.Type.Name == request.Type.Name);
                }
                if (true == request.TypeNames?.Any())
                {
                    entities = entities.Where(en => en.Type.Name.In(request.TypeNames));
                }
                if (true == request.UsersIds?.Any())
                {
                    entities = entities.Where(en => en.Users.Any(r => r.Id.In(request.UsersIds)));
                }

                entities = ApplyFilters <DocEntityUserType, UserTypeSearch>(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);
        }
Beispiel #4
0
 public object Post(UserTypeSearch request) => Get(request);