public async Task <PaginationApiResponse <ProviderDisplayShortModel> > GetAll(int skip, int limit, string languageCode = null, string search = null) { var total = int.Parse((await _repositoryProvider.Count(x => x.State == MREntityState.Active)).ToString()); var response = new PaginationApiResponse <ProviderDisplayShortModel>(skip, limit, total, new List <ProviderDisplayShortModel>()); var entities = await _repositoryProvider.GetSorted(x => x.State == MREntityState.Active, x => x.CreateTime, true, skip, limit); foreach (var entity in entities) { var name = entity.Name?.SelectTranslation(languageCode); var model = _mapper.Map <ProviderDisplayShortModel>(entity); model.Name = name?.Value; model.Categories = new List <CategoryDisplayModel>(); var categories = await _repositoryCategory.GetIn(x => x.Id, entity.Categories?.Select(x => x.Id)); if (categories != null && categories.Any()) { foreach (var c in categories) { var translation = c.Name.SelectTranslation(languageCode); model.Categories.Add(new CategoryDisplayModel { CreateTime = c.CreateTime, Id = c.Id, LanguageCode = languageCode, Name = translation?.Value }); } } response.List.Add(model); } return(response); }