internal virtual IPagedResultEntity <TEntity> MapToPagedResultEntity(PagedResultDtoEntity <TDtoEntity> pagedResultDtoEntity) { try { return(_mapper.Map <IPagedResultEntity <TEntity> >(pagedResultDtoEntity)); } catch (Exception apiRepositoryError) { _applicationLogTools.LogError(apiRepositoryError, new Dictionary <string, dynamic> { { "ClassName", $"WebApi.ApiControllerBase<{typeof(TEntity).Name}>" } }); throw; } }
/// <summary> /// Get all objects by partially populated object search in a sorted paged collection /// </summary> /// <param name="exampleSearchEntityPagingRequest"></param> /// <param name="subPathUri"></param> /// <returns></returns> internal virtual async Task <IPagedResultEntity <TEntity> > GetAllByExample(IPagedResultRequestEntity <TEntity> exampleSearchEntityPagingRequest, string subPathUri = null) { IPagedResultEntity <TEntity> currentReturnCollection = null; if (string.IsNullOrWhiteSpace(subPathUri)) { subPathUri = $"/api/{typeof(TEntity).Name}/GetAllByExample"; } try { PagedResultRequestDtoEntity <TDtoEntity> pagedResultRequestEntity = base.MapToPagedResultRequestDtoEntity <TEntity, TDtoEntity>(exampleSearchEntityPagingRequest); HttpResponseMessage responseResult = await base.ApiPostAsync(pagedResultRequestEntity, subPathUri); responseResult.EnsureSuccessStatusCode(); PagedResultDtoEntity <TDtoEntity> deserializedContent = JsonConvert.DeserializeObject <PagedResultDtoEntity <TDtoEntity> >(await responseResult.Content.ReadAsStringAsync()); currentReturnCollection = base.MapToPagedResultEntity <TEntity, TDtoEntity>(deserializedContent); } catch (Exception apiCommunicationError) { _applicationLogTools.LogError(apiCommunicationError, new Dictionary <string, dynamic> { { "ClassName", $"WebApi.ApiRepositoryStandard<{typeof(TEntity).Name}>" } }); if (Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT").Equals("Development", StringComparison.InvariantCultureIgnoreCase)) { throw; } else { return(null); } } return(currentReturnCollection); }