//ValidateWithConfim (Email, Password) public void Validate(ModelStateDictionary modelState) { ValidationCheck.CheckErrors(this, modelState, true); //check start and end date if (DateStart.CompareTo(DateEnd) >= 0) { modelState.AddModelError("DateEnd", "End Date must be greater than Start Date."); } try { CategoriesList = new List <long>(); if (!String.IsNullOrEmpty(Categories)) { CategoriesList.AddRange(Array.ConvertAll(Categories.Split(','), new Converter <string, long>(StringToLong))); } } catch (Exception ex) { modelState.AddModelError("Categories", ex.Message); } if (CategoriesList == null || CategoriesList.Count == 0) { modelState.AddModelError("CategoriesList", "Choose category(s) before updating this event."); } }
//ValidateWithConfim (Email, Password) public void ValidateWithConfim(System.Web.Mvc.ModelStateDictionary modelState) { ValidationCheck.CheckErrors(this, modelState, true); //check Login if (!ValidationCheck.IsEmpty(this.Login) && !ProjectConfig.Config.DataProvider.GetInstance().UserRepository.ValidateLogin(this.Login, ID)) { modelState.AddModelError("Login", "Login already exists. Please enter a different user name."); } //check Email if (!ValidationCheck.IsEmpty(this.Email) && !ProjectConfig.Config.DataProvider.GetInstance().UserRepository.ValidateEmail(this.Email, ID)) { modelState.AddModelError("Email", "A username for that e-mail address already exists. Please enter a different e-mail address."); } // check Email and Confirm Email if (!String.Equals(this.Email, this.ConfirmEmail, StringComparison.Ordinal)) { modelState.AddModelError("Email", "The Email and confirmation Email do not match."); modelState.AddModelError("ConfirmEmail", ""); } // check Password and Confirm Password if (!String.Equals(this.Password, this.ConfirmPassword, StringComparison.Ordinal)) { modelState.AddModelError("Password", "The password and confirmation password do not match."); modelState.AddModelError("ConfirmPassword", ""); } }
public void Validate(System.Web.Mvc.ModelStateDictionary modelState) { ValidationCheck.CheckErrors(this, modelState); //check Login if (!ValidationCheck.IsEmpty(this.Login) && !ProjectConfig.Config.DataProvider.GetInstance().UserRepository.ValidateLogin(this.Login, ID)) { modelState.AddModelError("Login", "This login already present in system"); } //check Email if (!ValidationCheck.IsEmpty(this.Email) && !ProjectConfig.Config.DataProvider.GetInstance().UserRepository.ValidateEmail(this.Email, ID)) { modelState.AddModelError("Email", "This email already present in system"); } if (!String.Equals(this.Password, this.ConfirmPassword, StringComparison.Ordinal)) { modelState.AddModelError("Password", "The password and confirmation password do not match."); modelState.AddModelError("ConfirmPassword", ""); } if (!String.Equals(this.Email, this.ConfirmEmail, StringComparison.Ordinal)) { modelState.AddModelError("Email", "The email and confirmation email do not match."); modelState.AddModelError("ConfirmEmail", ""); } if (this.BillingState == "--" && this.BillingCountry == 1) { modelState.AddModelError("BillingState", "'State' is required"); } if (this.ShippingState == "--" && this.ShippingCountry == 1 && !this.BillingLikeShipping) { modelState.AddModelError("ShippingState", "'State' is required"); } if (this.BillingState != "--" && this.BillingCountry > 1) { modelState.AddModelError("BillingState", "'State' must have value '--'"); } if (this.ShippingState != "--" && this.ShippingCountry > 1 && !this.BillingLikeShipping) { modelState.AddModelError("ShippingState", "'State' must have value '--'"); } if (this.BillingState == "--" && this.BillingCountry > 1 && String.IsNullOrEmpty(this.BillingInternationalState)) { modelState.AddModelError("BillingInternationalState", "'International State' is required"); } if (this.ShippingState == "--" && this.ShippingCountry > 1 && String.IsNullOrEmpty(this.ShippingInternationalState) && !this.BillingLikeShipping) { modelState.AddModelError("ShippingInternationalState", "'International State' is required"); } }
public void Validate(System.Web.Mvc.ModelStateDictionary modelState) { ValidationCheck.CheckErrors(this, modelState); if (!ValidationCheck.IsEmpty(this.Email) && ValidationCheck.IsEmail(this.Email)) { IUser user = ProjectConfig.DataProvider.UserRepository.GetUserByEmail(Email, false); if (user == null) { modelState.AddModelError("Email", "Sorry, the e-mail address entered was not found. Please try again."); } } }
private void ValidateModel(ModelBindingContext bindingContext) { ValidationCheck.CheckErrors(bindingContext.ModelMetadata.Model, bindingContext.ModelState); Type[] interfaces = bindingContext.ModelType.GetInterfaces(); foreach (Type type in interfaces) { if (type == typeof(IValidateModel)) { ((IValidateModel)bindingContext.Model).Validate(bindingContext.ModelState); break; } } }
//ValidateWithoutConfim public void ValidateWithoutConfim(System.Web.Mvc.ModelStateDictionary modelState) { ValidationCheck.CheckErrors(this, modelState, true); //check Login if (!ValidationCheck.IsEmpty(this.Login) && !ProjectConfig.Config.DataProvider.GetInstance().UserRepository.ValidateLogin(this.Login, ID)) { modelState.AddModelError("Login", "Login already exists. Please enter a different user name."); } //check Email if (!ValidationCheck.IsEmpty(this.Email) && !ProjectConfig.Config.DataProvider.GetInstance().UserRepository.ValidateEmail(this.Email, ID)) { modelState.AddModelError("Email", "A username for that e-mail address already exists. Please enter a different e-mail address."); } }
public void Validate(System.Web.Mvc.ModelStateDictionary modelState) { ValidationCheck.CheckErrors(this, modelState); if (!String.Equals(this.NewPassword, this.ConfirmPassword, StringComparison.Ordinal)) { modelState.AddModelError("NewPassword", "The new password and confirmation password do not match"); modelState.AddModelError("ConfirmPassword", ""); } SessionUser cuser = AppHelper.CurrentUser; if (!ProjectConfig.DataProvider.UserRepository.ValidatePasswordForUser(this.CurrentPassword, cuser != null ? cuser.ID : 0)) { modelState.AddModelError("CurrentPassword", "Current password is invalid"); } }
public void Validate(System.Web.Mvc.ModelStateDictionary modelState) { ValidationCheck.CheckErrors(this, modelState); if (String.IsNullOrEmpty(Email)) { modelState.AddModelError("Email", "<br /><br /><br /><br />Please enter your email address"); } if (!ValidationCheck.IsEmpty(this.Email) && !ProjectConfig.DataProvider.UserRepository.ValidateOuterSubscriptionEmail(this.Email, ID)) { modelState.AddModelError("Email", "<br /><br /><br /><br />This email already present in system"); } if (this.Email != this.EmailConfirm) { modelState.AddModelError("Email", "<br /><br /><br /><br />Email and confirmation email should be match."); } }
public void Validate(System.Web.Mvc.ModelStateDictionary modelState) { ValidationCheck.CheckErrors(this, modelState); //check Email if (!ValidationCheck.IsEmpty(this.Email) && !ProjectConfig.DataProvider.DifferentRepository.ValidateOuterSubscriptionEmail(this.Email, ID)) { modelState.AddModelError("Email", "This email already present in system"); } if (!(this.Email == this.EmailConfirm)) { modelState.AddModelError("Email", "Email and confirmation email should be match."); } if (!IsRecievingWeeklySpecials && !IsRecievingUpdates) { modelState.AddModelError("IsRecievingUpdates", "Select to recieve news and updates or/and weekly specials."); } }
//ValidateWithConfim (Email, Password) public void Validate(System.Web.Mvc.ModelStateDictionary modelState) { ValidationCheck.CheckErrors(this, modelState, true); }
public void Validate(System.Web.Mvc.ModelStateDictionary modelState) { ValidationCheck.CheckErrors(this, modelState); //check Login if (!ValidationCheck.IsEmpty(this.Login) && !ProjectConfig.Config.DataProvider.GetInstance().UserRepository.ValidateLogin(this.Login, ID)) { modelState.AddModelError("Login", "This login already present in system"); } //check Email if (!ValidationCheck.IsEmpty(this.Email) && !ProjectConfig.Config.DataProvider.GetInstance().UserRepository.ValidateEmail(this.Email, ID)) { modelState.AddModelError("Email", "This email already present in system"); } if (!String.Equals(this.Email, this.ConfirmEmail, StringComparison.Ordinal)) { modelState.AddModelError("Email", "The Email and confirmation Email do not match."); modelState.AddModelError("ConfirmEmail", ""); } if (!String.Equals(this.Password, this.ConfirmPassword, StringComparison.Ordinal)) { modelState.AddModelError("Password", "The password and confirmation password do not match."); modelState.AddModelError("ConfirmPassword", ""); } if (!ProjectConfig.Config.DataProvider.GetInstance().UserRepository.CheckChangePassword(this.ID, this.Password)) { modelState.AddModelError("Password", "Need to change and confirmation the password."); modelState.AddModelError("ConfirmPassword", ""); } if (!Agree) { modelState.AddModelError("Agree", "YOU MUST CHECK THE BOX BELOW"); } StringBuilder sb = new StringBuilder(BillingPhone); sb.Replace("(", "").Replace(")", "").Replace("-", "").Replace("_", "").Replace(" ", "").Replace("x", ""); BillingPhone = sb.ToString(); sb = new StringBuilder(BillingWorkPhone); sb.Replace("(", "").Replace(")", "").Replace("-", "").Replace("_", "").Replace(" ", "").Replace("x", ""); BillingWorkPhone = sb.ToString(); sb = new StringBuilder(ShippingPhone); sb.Replace("(", "").Replace(")", "").Replace("-", "").Replace("_", "").Replace(" ", "").Replace("x", ""); ShippingPhone = sb.ToString(); sb = new StringBuilder(ShippingWorkPhone); sb.Replace("(", "").Replace(")", "").Replace("-", "").Replace("_", "").Replace(" ", "").Replace("x", ""); ShippingWorkPhone = sb.ToString(); if (String.IsNullOrWhiteSpace(BillingPhone)) { modelState.AddModelError("BillingPhone", "The Phone number is required"); } if (String.IsNullOrWhiteSpace(ShippingPhone) && !BillingLikeShipping) { modelState.AddModelError("ShippingPhone", "The Phone number is required"); } //if ((modelState.ContainsKey("BillingPhone1") && modelState["BillingPhone1"].Errors.Count > 0) || (modelState.ContainsKey("BillingPhone2") && modelState["BillingPhone2"].Errors.Count > 0)) // modelState.AddModelError("BillingPhone", "Phone should contain digits only"); //if ((modelState.ContainsKey("BillingWorkPhone1") && modelState["BillingWorkPhone1"].Errors.Count > 0) || (modelState.ContainsKey("BillingWorkPhone2") && modelState["BillingWorkPhone2"].Errors.Count > 0)) // modelState.AddModelError("BillingWorkPhone", "Work Phone should contain digits only"); //if ((modelState.ContainsKey("ShippingPhone1") && modelState["ShippingPhone1"].Errors.Count > 0)) // modelState.AddModelError("ShippingPhone", "Phone should contain digits only"); //if ((modelState.ContainsKey("ShippingWorkPhone1") && modelState["ShippingWorkPhone1"].Errors.Count > 0) || (modelState.ContainsKey("ShippingWorkPhone2") && modelState["ShippingWorkPhone2"].Errors.Count > 0)) // modelState.AddModelError("ShippingWorkPhone", "Work Phone should contain digits only"); }