/// <summary> /// Get country form to create. /// </summary> /// <returns></returns> public async Task <ActionResult> GetCreateCountry() { CreateCountryFormData countryFormData = new CreateCountryFormData { TranslationsList = new List <CountryTranslationFormData>() }; LanguageResultData result = await WebApiClient.GetAsync <LanguageResultData>(Constant.WebApiControllerLanguages, Constant.WebApiLanguageList); if (result != null && result.OperationSuccess && result.LanguageDtoList != null) { foreach (var language in result.LanguageDtoList) { var translation = new CountryTranslationFormData { LanguagePrefix = language.LanguagePrefix, LanguageId = language.LanguageId, }; countryFormData.TranslationsList.Add(translation); } } ViewBag.Action = "CreateCountry"; return(PartialView("Partials/_CreateCountry", countryFormData)); }
/// <summary> /// validate create country translation. /// </summary> /// <param name="countryTranslationFormData">the countryTranslationFormData to validate.</param> /// <returns>true if the proportises are valide.</returns> public bool ValidateCountryTranslationFormData(CountryTranslationFormData countryTranslationFormData) { List <string> errors = new List <string>(); if (countryTranslationFormData == null) { errors.Add(SharedResources.NullFormData); } else { errors.AddRange( GenericValidationAttribute <CountryTranslationFormData> .ValidateAttributes("CountrySummary", countryTranslationFormData.CountrySummary)); errors.AddRange( GenericValidationAttribute <CountryTranslationFormData> .ValidateAttributes("CountryDescription", countryTranslationFormData.CountryDescription)); errors.AddRange(GenericValidationAttribute <CountryTranslationFormData> .ValidateAttributes("LanguageId", countryTranslationFormData.LanguageId.ToString())); errors.AddRange( GenericValidationAttribute <CountryTranslationFormData> .ValidateAttributes("CountryTitle", countryTranslationFormData.CountryTitle)); errors.AddRange(GenericValidationAttribute <CountryTranslationFormData> .ValidateAttributes("CountryName", countryTranslationFormData.CountryName)); } return(errors.Count == 0); }
/// <summary> /// From FORMDATA To REQUEST DATA /// </summary> /// <param name="countryTranslationFormData">form data to convert</param> /// <returns></returns> public static CountryTranslationRequestData ToRequestData(this CountryTranslationFormData countryTranslationFormData) { if (countryTranslationFormData == null) { return(new CountryTranslationRequestData()); } return(new CountryTranslationRequestData { CountryTranslationDtoList = new List <CountryTranslationItemData>(), CountryTranslationDto = countryTranslationFormData.ToItemData() }); }
/// <summary> /// FROM FROM DATA TO ITEM DATA. /// </summary> /// <param name="formData">the form data to convert.</param> /// <returns>the item data.</returns> public static CountryTranslationItemData ToItemData(this CountryTranslationFormData formData) { if (formData == null) { return(new CountryTranslationItemData()); } return(new CountryTranslationItemData { CountryDescription = formData.CountryDescription, CountrySummary = formData.CountrySummary, TranslationId = formData.TranslationId, CountryTitle = formData.CountryTitle, CountryName = formData.CountryName, LanguageId = formData.LanguageId, CountryId = formData.CountryId }); }
/// <summary> /// FROM itemData TO FORM DATA. /// </summary> /// <param name="itemData"></param> /// <returns></returns> public static CountryTranslationFormData ToFormData(this CountryTranslationItemData itemData) { if (itemData == null) { return(new CountryTranslationFormData()); } CountryTranslationFormData formData = new CountryTranslationFormData { LanguagePrefix = itemData.Language.LanguagePrefix, CountryDescription = itemData.CountryDescription, CountrySummary = itemData.CountrySummary, TranslationId = itemData.TranslationId, LanguageId = itemData.LanguageId ?? 0, CountryTitle = itemData.CountryTitle, CountryId = itemData.CountryId ?? 0, CountryName = itemData.CountryName }; return(formData); }