public ActionResult UsernameRecovery(UsernameRecoveryModel model) { FluentValidation.IValidator <UsernameRecoveryModel> validator = new UsernameRecoveryValidator(); var validationResults = validator.Validate(model); foreach (var item in validationResults.Errors) { ModelState.AddModelError(item.PropertyName, item.ErrorMessage); } if (ModelState.IsValid) { try { var result = _webClient.UploadData <int>("usernamerecovery", new { Email = model.Email }); // var result = _webClient.UploadData<int>("", new { Email = model.Email, Url = url }); //var result = 1; switch (result) { case 1: model.Result = Resource.UsernameRecovery_successmsg.ToString(); break; case 2: ModelState.AddModelError("", Resource.UsernameRecovery_msgnouser.ToString()); break; case 3: ModelState.AddModelError("", Resource.UsernameRecovery_msguseraccnotactive); break; case 4: ModelState.AddModelError("", Resource.UsernameRecovery_msguseraccdisabled); break; default: ModelState.AddModelError("", Resource.UsernameRecovery_unknownerror.ToString()); break; } } catch (Exception ex) { model.Result = ex.Message; } return(View(model)); } //If we got this far, something failed, redisplay form return(View(model)); }
public ActionResult UsernameRecovery() { var model = new UsernameRecoveryModel(); return(View(model)); }