Example #1
0
        public async Task <SearchResults <U> > Search <T, U>(HttpRequestMessage req, TraceWriter log) where T : BaseModel where U : class
        {
            var token         = req.GetQueryNameValuePairs().Where(w => w.Key == "token").FirstOrDefault().Value;
            var sort          = req.GetQueryNameValuePairs().Where(w => w.Key == "sort").FirstOrDefault().Value;
            var sortAscending = req.GetQueryNameValuePairs().Where(w => w.Key == "sortAscending").FirstOrDefault().Value;
            var pageSize      = req.GetQueryNameValuePairs().Where(w => w.Key == "pageSize").FirstOrDefault().Value;

            var filterNames = req.GetQueryNameValuePairs().Where(w => w.Key == "f").Select(q => q.Value).ToList();
            var values      = req.GetQueryNameValuePairs().Where(w => w.Key == "v").Select(q => q.Value).ToList();

            var filters = new List <GridQueryFilter>();

            for (int i = 0; i < filterNames.Count; i++)
            {
                filters.Add(new GridQueryFilter()
                {
                    column = filterNames[i], value = values.ElementAtOrDefault(i)
                });
            }

            var gridQuery = new GridQuery()
            {
                filters = filters,
                token   = token,
                sort    = sort,
            };

            int page;

            if (string.IsNullOrWhiteSpace(pageSize) == false && int.TryParse(pageSize, out page))
            {
                gridQuery.pageSize = page;
            }

            bool sortAsc = false;

            bool.TryParse(sortAscending, out sortAsc);
            gridQuery.sortAscending = sortAsc;

            var container    = ContainerRegistrar.GetContainer();
            var queryBuilder = container.GetInstance <IQueryBuilder <T, U> >();

            var userDigest = await _userDigestService.CurrentUserAsync(req);

            var searchResults = await _searchService.Search <T, U>(queryBuilder, token, gridQuery, userDigest);

            return(searchResults);
        }
        public void AllServicesRegistered()
        {
            container = ContainerRegistrar.GetContainer();

            var apiTypes = GetApiTypes();

            foreach (Type apiType in apiTypes)
            {
                try
                {
                    var controller = container.GetInstance(apiType);
                }
                catch (Exception ex)
                {
                    Assert.Fail(ex.ToString());
                }
            }

            // Stops the test runner crapping out in VSTS
            Thread.Sleep(1000 * 5);
        }