public SelectList GetAdminMenusCombobox() { return(adminMenuRepository.GetAll().Select(x => new ComboboxResult <int, string>() { Value = x.Id, Display = $"{x.Name} - {languageProviderService.GetlangByKey($"LBL_ADMINMENUITEM_{x.Name}")}" }).ToList().ToSelectList()); }
public SelectList GetRecordStatusCombobox() { List <ComboboxResult <long, string> > recordStatusComboboxs = new List <ComboboxResult <long, string> >() { new ComboboxResult <long, string>() { Value = ConstantConfig.RecordStatusConfig.Active, Display = languageProviderService.GetlangByKey("LBL_RECORDSTATUS_ACTIVE") }, new ComboboxResult <long, string>() { Value = ConstantConfig.RecordStatusConfig.Deleted, Display = languageProviderService.GetlangByKey("LBL_RECORDSTATUS_DELETE") } }; return(recordStatusComboboxs.ToSelectList()); }
public async Task <SelectList> GetPermissionCombobox() { List <PermissionDto> permissions = await GetAllPermissionDto(); List <ComboboxResult <string, string> > allPermissions = permissions.Select(x => new ComboboxResult <string, string>() { Value = x.Key.ToString(), Display = languageProviderService.GetlangByKey(x.Name) }).ToList(); return(allPermissions.ToSelectList()); }
public static string Lang(this IHtmlHelper helper, string key) { ILanguageProviderService languageService = helper.ViewContext.HttpContext.RequestServices.GetRequiredService <ILanguageProviderService>(); return(languageService.GetlangByKey(key)); }
/// <inheritdoc /> /// <remarks>Does nothing if <see cref="For"/> is <c>null</c>.</remarks> /// <exception cref="InvalidOperationException"> /// Thrown if <see cref="Format"/> is non-<c>null</c> but <see cref="For"/> is <c>null</c>. /// </exception> public override void Process(TagHelperContext context, TagHelperOutput output) { if (context == null) { throw new ArgumentNullException(nameof(context)); } if (output == null) { throw new ArgumentNullException(nameof(output)); } var validations = output.Attributes.Where(x => x.Name.ToString().Contains("data-val-")).ToArray(); if (LanguageSupport && validations.Any()) { foreach (var validation in validations) { output.Attributes.RemoveAll(validation.Name); string message = validation.Value.ToString(); output.Attributes.Add(validation.Name, languageProviderService.GetlangByKey(message)); } } // Pass through attributes that are also well-known HTML attributes. Must be done prior to any copying // from a TagBuilder. if (InputTypeName != null) { output.CopyHtmlAttribute("type", context); } if (Value != null) { output.CopyHtmlAttribute(nameof(Value), context); } // Note null or empty For.Name is allowed because TemplateInfo.HtmlFieldPrefix may be sufficient. // IHtmlGenerator will enforce name requirements. ModelMetadata metadata = For.Metadata; ModelExplorer modelExplorer = For.ModelExplorer; if (metadata == null) { return; } string inputType; string inputTypeHint; if (string.IsNullOrEmpty(InputTypeName)) { // Note GetInputType never returns null. inputType = GetInputType(modelExplorer, out inputTypeHint); } else { inputType = InputTypeName.ToLowerInvariant(); inputTypeHint = null; } // inputType may be more specific than default the generator chooses below. if (!output.Attributes.ContainsName("type")) { output.Attributes.SetAttribute("type", inputType); } TagBuilder tagBuilder; switch (inputType) { case "hidden": tagBuilder = GenerateHidden(modelExplorer); break; case "checkbox": GenerateCheckBox(modelExplorer, output); return; case "password": tagBuilder = Generator.GeneratePassword( ViewContext, modelExplorer, For.Name, value: null, htmlAttributes: null); break; case "radio": tagBuilder = GenerateRadio(modelExplorer); break; default: tagBuilder = GenerateTextBox(modelExplorer, inputTypeHint, inputType); break; } if (tagBuilder != null) { // This TagBuilder contains the one <input/> element of interest. output.MergeAttributes(tagBuilder); if (tagBuilder.HasInnerHtml) { // Since this is not the "checkbox" special-case, no guarantee that output is a self-closing // element. A later tag helper targeting this element may change output.TagMode. output.Content.AppendHtml(tagBuilder.InnerHtml); } } }
protected string GetLang(string code) { return(languageProvider.GetlangByKey(code)); }
public async Task <IActionResult> Add(UserInfoInput addInput) { if (!ModelState.IsValid) { string errorLangCode = ConstantConfig.WebApiResultMessage.Error; string errorMessage = languageService.GetlangByKey(errorLangCode); return(BadRequest(new { Message = errorMessage, ModelErrors = GetModelErrors() })); } bool result = await userService.Add(addInput); if (!result) { string errorLangCode = ConstantConfig.WebApiResultMessage.Error; string errorMessage = languageService.GetlangByKey(errorLangCode); return(BadRequest(errorMessage)); } return(Ok(addInput)); }