public async Task <IActionResult> Search([FromBody] JObject jObj)
        {
            if (jObj == null)
            {
                throw new ArgumentNullException(nameof(jObj));
            }

            EndpointTypes type;
            JToken        jType;

            if (!jObj.TryGetValue(Constants.EndpointNames.Type, out jType))
            {
                return(this.GetError(string.Format(Constants.Errors.ErrParamNotSpecified, Constants.EndpointNames.Type), HttpStatusCode.InternalServerError));
            }

            if (!Enum.TryParse(jType.ToString(), out type))
            {
                return(this.GetError(string.Format(Constants.Errors.ErrParamNotSpecified, Constants.EndpointNames.Type), HttpStatusCode.InternalServerError));
            }

            var parameter = new SearchEndpointsParameter
            {
                Type = type
            };

            var result = await _endpointRepository.Search(parameter);

            return(new OkObjectResult(ToJson(result)));
        }
        public async Task <IEnumerable <EndpointAggregate> > Search(SearchEndpointsParameter parameter)
        {
            if (parameter == null)
            {
                throw new ArgumentNullException(nameof(parameter));
            }

            using (var serviceScope = _serviceProvider.GetRequiredService <IServiceScopeFactory>().CreateScope())
            {
                using (var context = serviceScope.ServiceProvider.GetService <ProfileDbContext>())
                {
                    IQueryable <Endpoint> endpoints = context.Endpoints;
                    if (parameter.Type != null)
                    {
                        endpoints = endpoints.Where(e => e.Type == (int)parameter.Type.Value);
                    }

                    return(await endpoints.Select(i => GetIdProvider(i)).ToListAsync().ConfigureAwait(false));
                }
            }
        }