protected void EnsureValidity(IValidationState validationState, string message) { if (!validationState.IsValid) { var errors = validationState.AllResultDescriptions.Select(rd => rd); throw new HttpException(HttpStatusCode.BadRequest, message, errors); } }
public AccountController(IFormsAuthentication authService, IValidationService validationService, IMembershipService membershipService, IValidationState validationState) { this.formsAuthentication = authService; this.validationService = validationService; this.membershipService = membershipService; this.captchaValidator = new DefaultCaptchaValidator(validationState) { // This is disabled so the functional tests do not fail. // In real world application this option can be managed by // build process. Enabled = false }; }
public ActionResult ChangePassword(ChangePasswordViewModel model) { if (ModelState.IsValid) { IValidationState validationState = memberService.ChangePassword(HttpContext.User.Identity.Name, model.OldPassword, model.NewPassword); if (!validationState.IsValid) { ModelState.MergeError(validationState); } else { return(RedirectToAction("ChangePasswordSuccess")); } } return(View(model)); }
public ActionResult LogOn(LogonViewModel model) { if (ModelState.IsValid) { IValidationState validationState = memberService.ValidatePassword(model.MemberName, model.Password); if (!validationState.IsValid) { ModelState.MergeError(validationState); } else { FormsAuthenticationService.SignIn(model.MemberName, model.RememberMe); return(RedirectToAction("Index", "Home")); } } return(View(model)); }
public ActionResult EditProfile(EditUserProfileViewModel model) { if (ModelState.IsValid) { var user = userService.GetUser(HttpContext.User.Identity.Name); user = Mapper.Map <EditUserProfileViewModel, Models.User>(model, user); IValidationState validationState = userService.UpdateUser(user); if (!validationState.IsValid) { ModelState.MergeError(validationState); } else { return(RedirectToAction("Index")); } } return(View(model)); }
public ActionResult Register(RegisterViewModel model) { if (ModelState.IsValid) { Guid memberId; IValidationState memberValidationState = memberService.CreateMember(model.MemberName, model.Password, out memberId); userService.CreateUser(new Models.User() { Id = memberId, UserName = model.MemberName }); if (!memberValidationState.IsValid) { ModelState.MergeError(memberValidationState); } else { FormsAuthenticationService.SignIn(model.MemberName, false); return(RedirectToAction("Index", "Home")); } } return(View(model)); }
public ServiceResponse(TEntity entity, TContract contract, IValidationState validationState) { Entity = entity; Contract = contract; ValidationState = validationState; }
public ValidationService(IValidationState validationState, IValidatorFactory validatorFactory) { m_validationState = validationState; m_validatorFactory = validatorFactory ?? ValidatorFactoryCache.Instance; }
public ValidationService(IValidationState validationState) : this(validationState, null) { }
public RunOnceService(ICache cache, TimeSpan period, IValidationState validationState) { m_cache = cache; m_period = period; m_validationState = validationState; }
protected IServiceResponse <TEntity, TContract> Response <TEntity, TContract>(TEntity entity, TContract contract, IValidationState validationState) where TEntity : class where TContract : class { return(ServiceResponse <TEntity, TContract> .Create(entity, contract, validationState)); }
protected IServiceResponse <TEntity, TEntity> Response <TEntity>(TEntity entity, IValidationState validationState) where TEntity : class { return(Response(entity, entity, validationState)); }
public ViewStateValidator() { failures = new Dictionary <string, ValidationFailure>(); State = new ValidationState(failures); }
public DefaultCaptchaValidator(IValidationState state) { m_state = state; Enabled = true; }