/// <summary> /// Gets an <see cref="ApplicationLanguageViewModel"/> by its ISO-639 code. /// </summary> /// <param name="code">The code of the language to retrieve from the database.</param> /// <returns>If a corresponding entity is found in the database, converts and returns it. Otherwise, returns null.</returns> public ApplicationLanguageViewModel GetApplicationLanguageByCode(string code) { var converter = new ApplicationLanguageConverter(); var entity = _repository.GetUiLanguageByCode(code); return(converter.To(entity)); }
/// <summary> /// Gets all the available <see cref="UiLanguage"/> entities from the database, converts them to <see cref="ApplicationLanguageViewModel"/>s, and returns them. /// </summary> /// <returns>A (possibly empty) list of <see cref="ApplicationLanguageViewModel"/> objects.</returns> public IEnumerable <ApplicationLanguageViewModel> GetAllApplicationLanguages() { var converter = new ApplicationLanguageConverter(); var result = _repository.GetAllUiLanguages(); var output = new List <ApplicationLanguageViewModel>(); foreach (var uiLanguage in result) { output.Add(converter.To(uiLanguage)); } return(output); }