public IActionResult Index()
        {
            var model = new InstallationModel
            {
                AdminEmail = _installService.GetResource("AdminEmailValue")
            };

            var curLanguage = _installService.GetCurrentLanguage();

            var installLanguages = _installService.GetInstallationLanguages()
                                   .Select(x =>
            {
                return(new SelectListItem
                {
                    Value = Url.Action("ChangeLanguage", "Install", new { language = x.Code }),
                    Text = x.Name,
                    Selected = curLanguage.Code == x.Code
                });
            })
                                   .ToList();

            var appLanguages = _installService.GetAppLanguages()
                               .Select(x =>
            {
                return(new SelectListItem
                {
                    Value = x.Culture,
                    Text = x.Name,
                    Selected = x.UniqueSeoCode.EqualsNoCase(curLanguage.Code)
                });
            })
                               .ToList();

            if (!appLanguages.Any(x => x.Selected))
            {
                appLanguages.FirstOrDefault(x => x.Value.EqualsNoCase("en")).Selected = true;
            }

            ViewBag.AvailableInstallationLanguages = installLanguages;
            ViewBag.AvailableAppLanguages          = appLanguages;

            ViewBag.AvailableMediaStorages = new[]
            {
                new SelectListItem {
                    Value = "fs", Text = _installService.GetResource("MediaStorage.FS"), Selected = true
                },
                new SelectListItem {
                    Value = "db", Text = _installService.GetResource("MediaStorage.DB")
                }
            };

            return(View(model));
        }
示例#2
0
        public InstallationModelValidator(IInstallationService installService)
        {
            RuleFor(x => x.AdminEmail).NotEmpty().WithMessage(installService.GetResource("AdminEmailRequired")).EmailAddress();
            RuleFor(x => x.AdminPassword).NotEmpty().WithMessage(installService.GetResource("AdminPasswordRequired"));
            RuleFor(x => x.ConfirmPassword).NotEmpty().WithMessage(installService.GetResource("ConfirmPasswordRequired"));
            RuleFor(x => x.AdminPassword).Equal(x => x.ConfirmPassword).WithMessage(installService.GetResource("PasswordsDoNotMatch"));
            RuleFor(x => x.DataProvider).NotEmpty();
            RuleFor(x => x.PrimaryLanguage).NotEmpty();

            RuleFor(x => x.DbRawConnectionString).NotEmpty().When(x => x.UseRawConnectionString).WithMessage(installService.GetResource("DbRawConnectionStringRequired"));
            RuleFor(x => x.DbServer).NotEmpty().When(x => !x.UseRawConnectionString).WithMessage(installService.GetResource("DbServerRequired"));
            RuleFor(x => x.DbName).NotEmpty().When(x => !x.UseRawConnectionString).WithMessage(installService.GetResource("DbNameRequired"));

            RuleFor(x => x.DbUserId).NotEmpty()
            .When(x => !x.UseRawConnectionString && x.DbAuthType != "windows")
            .WithMessage(installService.GetResource("DbUserIdRequired"));
        }
示例#3
0
 public InstallationModelValidator(IInstallationService installService)
 {
     RuleFor(x => x.AdminEmail).NotEmpty().EmailAddress();
     RuleFor(x => x.AdminPassword).NotEmpty();
     RuleFor(x => x.ConfirmPassword).NotEmpty();
     RuleFor(x => x.AdminPassword).Equal(x => x.ConfirmPassword).WithMessage(installService.GetResource("PasswordsDoNotMatch"));
     RuleFor(x => x.DataProvider).NotEmpty();
     RuleFor(x => x.PrimaryLanguage).NotEmpty();
 }