/// <summary> /// Gets the language translations. /// </summary> /// <param name="languageTranslationQueryParameters">The language translation query parameters.</param> /// <returns></returns> public async Task <CSSResponse> GetLanguageTranslations(LanguageTranslationQueryParameters languageTranslationQueryParameters) { var languageTranslations = await _repository.LanguageTranslation.GetLanguageTranslations(languageTranslationQueryParameters); _httpContextAccessor.HttpContext.Response.Headers.Add("X-Pagination", PagedList <Entity> .ToJson(languageTranslations)); return(new CSSResponse(languageTranslations, HttpStatusCode.OK)); }
/// <summary> /// Gets the language translations. /// </summary> /// <param name="languageTranslationQueryParameters">The language translation query parameters.</param> /// <returns></returns> public async Task <PagedList <Entity> > GetLanguageTranslations(LanguageTranslationQueryParameters languageTranslationQueryParameters) { var languages = FindByCondition(x => x.IsDeleted == false); var filteredLanguages = FilterLanguages(languages, languageTranslationQueryParameters); var sortedSchedulingCodes = SortHelper.ApplySort(filteredLanguages, languageTranslationQueryParameters.OrderBy); var pagedLanguages = sortedSchedulingCodes .Skip((languageTranslationQueryParameters.PageNumber - 1) * languageTranslationQueryParameters.PageSize) .Take(languageTranslationQueryParameters.PageSize) .Include(x => x.Language) .Include(x => x.Menu) .Include(x => x.Variable); var mappedLanguages = pagedLanguages .ProjectTo <LanguageTranslationDTO>(_mapper.ConfigurationProvider); var shapedSchedulingCodes = DataShaper.ShapeData(mappedLanguages, languageTranslationQueryParameters.Fields); return(await PagedList <Entity> .ToPagedList(shapedSchedulingCodes, filteredLanguages.Count(), languageTranslationQueryParameters.PageNumber, languageTranslationQueryParameters.PageSize)); }
/// <summary> /// Filters the languages. /// </summary> /// <param name="languages">The languages.</param> /// <param name="languageTranslationQueryParameters">The language translation query parameters.</param> /// <returns></returns> private IQueryable <LanguageTranslation> FilterLanguages(IQueryable <LanguageTranslation> languages, LanguageTranslationQueryParameters languageTranslationQueryParameters) { if (!languages.Any()) { return(languages); } if (languageTranslationQueryParameters.LanguageId.HasValue && languageTranslationQueryParameters.LanguageId != default(int)) { languages = languages.Where(x => x.LanguageId == languageTranslationQueryParameters.LanguageId); } if (languageTranslationQueryParameters.MenuId.HasValue && languageTranslationQueryParameters.MenuId != default(int)) { languages = languages.Where(x => x.MenuId == languageTranslationQueryParameters.MenuId); } if (languageTranslationQueryParameters.VariableId.HasValue && languageTranslationQueryParameters.VariableId != default(int)) { languages = languages.Where(x => x.VariableId == languageTranslationQueryParameters.VariableId); } if (!string.IsNullOrWhiteSpace(languageTranslationQueryParameters.SearchKeyword)) { languages = languages.Where(o => o.Translation.ToLower().Contains(languageTranslationQueryParameters.SearchKeyword.Trim().ToLower()) || o.CreatedBy.ToLower().Contains(languageTranslationQueryParameters.SearchKeyword.Trim().ToLower()) || o.ModifiedBy.ToLower().Contains(languageTranslationQueryParameters.SearchKeyword.Trim().ToLower())); } return(languages); }
public async Task <IActionResult> GetLanguageTranslations([FromQuery] LanguageTranslationQueryParameters translationQueryParameters) { var result = await _languageTranslationService.GetLanguageTranslations(translationQueryParameters); return(StatusCode((int)result.Code, result.Value)); }