public async Task <List <DetailLog> > GetAllErrors(ErrorLogCollectionSearch errorLogDisplaySearch) { var query = _context.DetailLogs.AsQueryable(); List <DetailLog> result = null; if (!string.IsNullOrEmpty(errorLogDisplaySearch.Assembly)) { query = query.Where(x => x.Assembly == errorLogDisplaySearch.Assembly); } if (!string.IsNullOrEmpty(errorLogDisplaySearch.RequestPath)) { query = query.Where(x => x.RequestPath == errorLogDisplaySearch.RequestPath); } if (errorLogDisplaySearch.DateFrom != null) { query = query.Where(x => x.TimeStamp >= errorLogDisplaySearch.DateFrom); } if (errorLogDisplaySearch.DateTo != null) { query = query.Where(x => x.TimeStamp <= errorLogDisplaySearch.DateTo); } await _retryPolicy.ExecuteAsync(async() => { result = await query.Where(x => x.Level == "Error").ToListAsync(); }); return(result); }
public async Task <PagedList <ErrorLogCollection> > GetAllError(ErrorLogCollectionSearch errorLogDisplaySearch) { var perfLogFromRepo = await _detailLogService.GetAllErrors(errorLogDisplaySearch); var errorLogs = _mapper.Map <List <ErrorLogCollection> >(perfLogFromRepo); var result = PagedList <ErrorLogCollection> .Create(errorLogs, errorLogDisplaySearch.PageNumber, errorLogDisplaySearch.PageSize); return(result); }
private string CreateGetLink(ErrorLogCollectionSearch errorLogDisplaySearch, int pageNumber) { return(Url.Link("GetErrorLogs", new ErrorLogCollectionSearch() { PageNumber = pageNumber, PageSize = errorLogDisplaySearch.PageSize, RequestPath = errorLogDisplaySearch.RequestPath, Assembly = errorLogDisplaySearch.Assembly })); }
public async Task GetAllErrors() { //arrange var DetailLogRepository = new DetailLogRepository(_context, PollyTestFactory.CreateAsyncRetryPolicy()); var errorLogDisplaySearch = new ErrorLogCollectionSearch(); //act var value = await DetailLogRepository.GetAllErrors(errorLogDisplaySearch); //assert Assert.Equal(6, value.Count()); }
public async Task Refresh() { var search = new ErrorLogCollectionSearch() { PageSize = ShowPageSize, OrderBy = OrderBy, OrderAscending = OrderAscending, PageNumber = PageNumber }; ErrorLogs = Mapper.Map <ErrorLogPagedList>(await ErrorLogService.Search(search)); }
public async Task GetAllErrors_RequestPath_Count(string requestPath, int expected) { //arrange var DetailLogRepository = new DetailLogRepository(_context, PollyTestFactory.CreateAsyncRetryPolicy()); var errorLogDisplaySearch = new ErrorLogCollectionSearch() { RequestPath = requestPath }; //act var value = await DetailLogRepository.GetAllErrors(errorLogDisplaySearch); //assert Assert.Equal(expected, value.Count()); }
public async Task GetAllErrors_DateToSearch_Count(string dateTo, int expected) { //arrange var DetailLogRepository = new DetailLogRepository(_context, PollyTestFactory.CreateAsyncRetryPolicy()); var errorLogDisplaySearch = new ErrorLogCollectionSearch() { DateTo = DateTime.Parse(dateTo) }; //act var value = await DetailLogRepository.GetAllErrors(errorLogDisplaySearch); //assert Assert.Equal(expected, value.Count()); }
public async Task GetAllErrors_Search_Count() { //arrange var DetailLogRepository = new DetailLogRepository(_context, PollyTestFactory.CreateAsyncRetryPolicy()); var errorLogDisplaySearch = new ErrorLogCollectionSearch() { Assembly = "Hippologamus.API", DateFrom = new DateTime(2020, 1, 2), DateTo = new DateTime(2020, 1, 5) }; //act var value = await DetailLogRepository.GetAllErrors(errorLogDisplaySearch); //assert Assert.Equal(3, value.Count()); }
private IEnumerable <RootLink> CreateGetLinks(ErrorLogCollectionSearch errorLogDisplaySearch, bool hasNext, bool hasPrevious) { var links = new List <RootLink> { new RootLink(CreateGetLink(errorLogDisplaySearch, errorLogDisplaySearch.PageNumber), "self", "GET") }; if (hasNext) { links.Add(new RootLink(CreateGetLink(errorLogDisplaySearch, errorLogDisplaySearch.PageNumber + 1), "nextPage", "GET")); } if (hasPrevious) { links.Add(new RootLink(CreateGetLink(errorLogDisplaySearch, errorLogDisplaySearch.PageNumber - 1), "previousPage", "GET")); } return(links); }
public async Task <IActionResult> Get([FromQuery] ErrorLogCollectionSearch errorLogDisplaySearch) { var perfLogs = await _errorLogManager.GetAllError(errorLogDisplaySearch); var paginationMetadata = new { totalCount = perfLogs.TotalCount, pageSize = perfLogs.PageSize, currentPage = perfLogs.CurrentPage, totalPages = perfLogs.TotalPages }; Response.Headers.Add("X-Pagination", JsonSerializer.Serialize(paginationMetadata)); var links = CreateGetLinks(errorLogDisplaySearch, perfLogs.HasNext, perfLogs.HasPrevious); var perfLogsToReturn = new { value = perfLogs, links }; return(Ok(perfLogsToReturn)); }
public async Task <List <DetailLog> > GetAllErrors(ErrorLogCollectionSearch errorLogDisplaySearch) { return(await _detailLogRepository.GetAllErrors(errorLogDisplaySearch)); }
public async Task <ErrorLogCollectionResponce> Search(ErrorLogCollectionSearch search) { var response = await _httpClient.GetAsync($"api/ErrorLog?{ObjectToURLStringFactory.Create(search)}"); return(await ConvertResponseToErrorLogCollectionResponce(response)); }