/// <summary> /// Constructor method. /// </summary> public ProfileEditViewModelValidator(SharedContext context, IIdentityRepository identityRepository) { _context = context; _identityRepository = identityRepository; // Name RuleFor(model => model.FullName).NotEmpty(); RuleFor(model => model.FullName).Length(0, _Constants.UsersFullNameMaxLength).WithMessage(GlobalizationManager.GetLocalizedString("_Validation_MaxLength")); // Email RuleFor(model => model.Email).NotEmpty(); RuleFor(model => model.Email).Matches(_RegularExpressions.SimpleEmailPattern); RuleFor(model => model.Email).Length(0, _Constants.UsersEmailMaxLength).WithMessage(GlobalizationManager.GetLocalizedString("_Validation_MaxLength")); RuleFor(model => model.Email).Must(BeUniqueOrCurrentEmail).WithMessage(GlobalizationManager.GetLocalizedString("_Validation_EmailTakenError")); // Username RuleFor(model => model.UserName).NotEmpty(); RuleFor(model => model.UserName).Matches(_RegularExpressions.UserNamePattern); RuleFor(model => model.UserName).Length(0, _Constants.UsersUserNameMaxLength).WithMessage(GlobalizationManager.GetLocalizedString("_Validation_MaxLength")); RuleFor(model => model.UserName).Must(BeUniqueOrCurrentUsername).WithMessage(GlobalizationManager.GetLocalizedString("_Validation_UserNameTakenError")); // Picture Blob Id RuleFor(model => model.PictureBlobId).Must(BeExistingPictureBlobId).WithMessage(GlobalizationManager.GetLocalizedString("_Validation_BlobIdInvalidError")); // Globalization RuleFor(model => model.CultureId).NotEmpty(); RuleFor(model => model.UICultureId).NotEmpty(); RuleFor(model => model.TimeZoneId).NotEmpty(); }
/// <summary> /// Constructor method. /// </summary> public ErrorViewModel(HttpStatusCode statusCode, string errorMessage = null) { Code = (int)statusCode; Message = errorMessage; if (!string.IsNullOrWhiteSpace(Message)) { return; } switch (statusCode) { case HttpStatusCode.BadRequest: Message = GlobalizationManager.GetLocalizedString("Errors_BadRequestMessage"); break; case HttpStatusCode.Forbidden: Message = GlobalizationManager.GetLocalizedString("Errors_ForbiddenMessage"); break; case HttpStatusCode.NotFound: Message = GlobalizationManager.GetLocalizedString("Errors_NotFoundMessage"); break; case HttpStatusCode.Unauthorized: Message = GlobalizationManager.GetLocalizedString("Errors_UnauthorizedMessage"); break; default: Message = GlobalizationManager.GetLocalizedString("Errors_GeneralErrorMessage"); break; } }
public AccountSignUpViewModelValidator(IIdentityRepository identityRepository) { _identityRepository = identityRepository; // Name RuleFor(model => model.Name).NotEmpty(); RuleFor(model => model.Name).Length(0, _Constants.UsersFullNameMaxLength).WithMessage(GlobalizationManager.GetLocalizedString("_Validation_MaxLength")); // Email RuleFor(model => model.Email).NotEmpty(); RuleFor(model => model.Email).Matches(_RegularExpressions.SimpleEmailPattern); RuleFor(model => model.Email).Length(0, _Constants.UsersEmailMaxLength).WithMessage(GlobalizationManager.GetLocalizedString("_Validation_MaxLength")); RuleFor(model => model.Email).Must(BeUniqueEmail).WithMessage(GlobalizationManager.GetLocalizedString("_Validation_EmailTakenError")); // Password RuleFor(model => model.Password).NotEmpty(); RuleFor(model => model.Password).Length(_Constants.UsersPasswordMinLength, int.MaxValue).WithMessage(GlobalizationManager.GetLocalizedString("_Validation_MinLength")); // Confirm Password RuleFor(model => model.Password2).NotEmpty(); RuleFor(model => model.Password2).Equal(model => model.Password).WithMessage(GlobalizationManager.GetLocalizedString("_Validation_PasswordsDoNotMatchError")); // Terms Of Use Acceptance RuleFor(model => model.TermsAcceptance).SetValidator(new RequiredCheckboxValidator()).WithMessage(GlobalizationManager.GetLocalizedString("_Validation_TermsAcceptanceError")); }
protected void Application_BeginRequest(Object sender, EventArgs e) { var context = new HttpContextWrapper(HttpContext.Current); GlobalizationManager.SetCurrentCulture(context); context.Response.Headers["Access-Control-Expose-Headers"] = "LoginUrl"; }
protected void Application_BeginRequest(Object sender, EventArgs e) { var context = new HttpContextWrapper(HttpContext.Current); ExperimentManager.AssignExperiment(context); GlobalizationManager.SetCurrentCulture(context); //if (context.Request.Cookies[Constants.TiPCookie] == null && // context.Request.QueryString[Constants.TiPCookie] != null) //{ // context.Response.Cookies.Add(new HttpCookie(Constants.TiPCookie, context.Request.QueryString[AuthConstants.TiPCookie]) { Path = "/" }); //} }
public ActionResult ChangeLanguage(int CurrentLangId) { if (SessionHandler.Instance.Get(SessionEnum.Language_Info) == null) { GlobalizationManager _GlobalizationManager = new GlobalizationManager(); SessionHandler.Instance.Set(_GlobalizationManager, SessionEnum.Language_Info); } // Set Language Information. ManageUserLanguage(CurrentLangId); //Fill View Model. Models.HomeVM_UI model = new Models.HomeVM_UI(); model.currentUser = SessionHandler.Instance.Get <UserViewModel>(SessionEnum.User_Info); return(RedirectToAction("Index", "home", new { LangId = CurrentLangId })); // }
private void ManageUserLanguage(int userLangID) { try { string direction = "RTL"; if (userLangID == 2) { direction = "LTR"; } GlobalizationManager _GlobalizationManager; SessionHandler.Instance.Remove(SessionEnum.Language_Info); if (userLangID != LocalizationService.GetLanguageID("Default")) { string module = (ApplicationService.GetByID(Apps.MaskanWeb)).ApplicationName; DataSet ds_ModuleWL = LocalizationService.GetModule(Convert.ToInt32(userLangID), module, true); Session["loginISRTL"] = false; if (ds_ModuleWL != null) { _GlobalizationManager = new GlobalizationManager(ds_ModuleWL, direction); } else { _GlobalizationManager = new GlobalizationManager(tb_GUI_Lang); } SessionHandler.Instance.Set(_GlobalizationManager, SessionEnum.Language_Info); } else { _GlobalizationManager = new GlobalizationManager(tb_GUI_Lang); SessionHandler.Instance.Set(_GlobalizationManager, SessionEnum.Language_Info); } } catch (Exception ex) { Session["ds_Language_WL"] = null; } }
public UserViewModelValidator(IIdentityRepository identityRepository) { _identityRepository = identityRepository; // Validate name and email only when adding new user. When(model => model.Id <= 0, () => { // Name RuleFor(model => model.FullName).NotEmpty(); RuleFor(model => model.FullName).Length(0, _Constants.UsersFullNameMaxLength).WithMessage(GlobalizationManager.GetLocalizedString("_Validation_MaxLength")); // Email RuleFor(model => model.Email).NotEmpty(); RuleFor(model => model.Email).Matches(_RegularExpressions.SimpleEmailPattern); RuleFor(model => model.Email).Length(0, _Constants.UsersEmailMaxLength).WithMessage(GlobalizationManager.GetLocalizedString("_Validation_MaxLength")); RuleFor(model => model.Email).Must(BeUniqueEmail).WithMessage(GlobalizationManager.GetLocalizedString("_Validation_EmailTakenError")); }); // Realms RuleFor(model => model.Realms).NotEmpty(); // Roles RuleFor(model => model.Roles).NotEmpty(); }
protected string GetLocalizedString(string resourceKey, params object[] formatParams) { return(GlobalizationManager.GetLocalizedString(resourceKey, formatParams)); }
public AccountPasswordRecoverViewModelValidator() { // Email RuleFor(model => model.Email).NotEmpty(); RuleFor(model => model.Email).Matches(_RegularExpressions.SimpleEmailPattern); RuleFor(model => model.Email).Length(0, _Constants.UsersEmailMaxLength).WithMessage(GlobalizationManager.GetLocalizedString <AreaResources>("_Validation_MaxLength")); }
/// <summary> /// Constructor method. /// </summary> public AccountPasswordChangeViewModelValidator() { // Password RuleFor(model => model.Password).NotEmpty(); RuleFor(model => model.Password).Length(_Constants.UsersPasswordMinLength, int.MaxValue).WithMessage(GlobalizationManager.GetLocalizedString <AreaResources>("_Validation_MinLength")); // New Password RuleFor(model => model.NewPassword).NotEmpty(); RuleFor(model => model.NewPassword).Length(_Constants.UsersPasswordMinLength, int.MaxValue).WithMessage(GlobalizationManager.GetLocalizedString <AreaResources>("_Validation_MinLength")); // New Password Confirmation RuleFor(model => model.NewPassword2).NotEmpty(); RuleFor(model => model.NewPassword2).Equal(model => model.NewPassword).WithMessage(GlobalizationManager.GetLocalizedString <AreaResources>("_Validation_PasswordsDoNotMatchError")); }
public static List <Globalization> GetGlobalizationByUserLanguage(int langID) { GlobalizationManager gm = new GlobalizationManager(); return(gm.FilterGlobalizationBasedOnUserLanguage(langID)); }
public GlobalizationRedirect(GlobalizationManager globalization) { this.Globalization = globalization; }
/// <summary> /// Constructor method. /// </summary> public UploadPictureViewModelValidator() { // Image RuleFor(model => model.Picture).NotNull(); RuleFor(model => model.Picture).Must(BeOfValidContentLength).WithMessage(model => string.Format(GlobalizationManager.GetLocalizedString("_Validation_BlobSizeLimitError"), model?.Picture?.FileName ?? string.Empty) ); RuleFor(model => model.Picture).Must(BeImageMimeType).WithMessage(model => string.Format(GlobalizationManager.GetLocalizedString("_Validation_BlobImageMimeTypeError", model?.Picture?.FileName ?? string.Empty)) ); }
public AccountPasswordRecoverResponseViewModelValidator() { // Email RuleFor(model => model.Email).NotEmpty(); RuleFor(model => model.Email).Matches(_RegularExpressions.SimpleEmailPattern); RuleFor(model => model.Email).Length(0, _Constants.UsersEmailMaxLength).WithMessage(GlobalizationManager.GetLocalizedString("_Validation_MaxLength")); // Password RuleFor(model => model.NewPassword).NotEmpty(); RuleFor(model => model.NewPassword).Length(_Constants.UsersPasswordMinLength, int.MaxValue).WithMessage(GlobalizationManager.GetLocalizedString("_Validation_MinLength")); // Confirm Password RuleFor(model => model.NewPassword2).NotEmpty(); RuleFor(model => model.NewPassword2).Equal(model => model.NewPassword).WithMessage(GlobalizationManager.GetLocalizedString("_Validation_PasswordsDoNotMatchError")); }
public GlobalizationRedirect(GlobalizationManager globalization) { this.Globalization = globalization; }