/// <summary> /// Search CountryTranslation by id. /// </summary> /// <param name="request">The CountryTranslation Request Pivot to retrive.</param> /// <returns>CountryTranslation Response Pivot response.</returns> public CountryTranslationResponsePivot FindCountryTranslations(CountryTranslationRequestPivot request) { if (request.CountryTranslationPivot == null) { throw new ArgumentNullException(nameof(request)); } List <CountryTranslationPivot> results = new List <CountryTranslationPivot>(); CountryTranslationPivot result = new CountryTranslationPivot(); switch (request.FindCountryTranslationPivot) { case FindCountryTranslationPivot.CountryTranslationId: result = _unitOfWork.CountryTranslationRepository.Get(c => c.TranslationId == request.CountryTranslationPivot.TranslationId, null, "Country,Language")?.FirstOrDefault().ToPivot(); break; case FindCountryTranslationPivot.CountryId: results = _unitOfWork.CountryTranslationRepository.Get(c => c.CountryId == request.CountryTranslationPivot.CountryId, null, "Country,Language")?.ToList().ToPivotList(); break; } return(new CountryTranslationResponsePivot() { CountryTranslationPivotList = results, CountryTranslationPivot = result }); }
/// <summary> /// From CountryTranslation Pivot To CountryTranslation Dto. /// </summary> /// <param name="countryTranslationPivot">countryTranslation pivot to assemble.</param> /// <returns>CountryTranslationDto result.</returns> public static CountryTranslationDto ToDto(this CountryTranslationPivot countryTranslationPivot) { if (countryTranslationPivot == null) { return(null); } return(new CountryTranslationDto() { TranslationId = countryTranslationPivot.TranslationId, CountryName = countryTranslationPivot.CountryName, CountryTitle = countryTranslationPivot.CountryTitle, CountryDescription = countryTranslationPivot.CountryDescription, CountrySummary = countryTranslationPivot.CountrySummary, CountryId = countryTranslationPivot.CountryId, Country = countryTranslationPivot.Country.ToDto(), LanguageId = countryTranslationPivot.LanguageId, Language = countryTranslationPivot.Language.ToDto(), }); }