Example #1
0
        public void Search_Count_Should_Return_All_Valid_Ressource_Server_Number_Without_Search_Criterias()
        {
            var total = _service.SearchCount(new RessourceServerSearchDto()
            {
                Limit = 50,
                Skip  = 0,
                Login = String.Empty,
                Name  = String.Empty
            });

            var expected = FakeDataBase.Instance.RessourceServers.Where(r => r.IsValid.Equals(true)).Count();

            Assert.AreEqual(expected, total);
        }
Example #2
0
        public IActionResult GetAll(string name, string login, uint skip, uint limit)
        {
            var criterias = new RessourceServerSearchDto()
            {
                Name  = name,
                Login = login,
                Skip  = skip,
                Limit = limit
            };

            var count = _service.SearchCount(criterias);

            Request.HttpContext.Response.Headers.Add("X-Total-Count", count.ToString());
            if (Request.Method.Equals("head", StringComparison.OrdinalIgnoreCase))
            {
                return(Ok());
            }
            else
            {
                var clients    = _service.Search(criterias);
                var currentUrl = UriHelper.GetDisplayUrl(Request);
                return(Ok(clients.ToSearchResult <RessourceServerDto>(currentUrl, count, criterias)));
            }
        }