protected override ValidationResult IsValid(object value, ValidationContext validationContext) { GenerateTestYourselfViewModel model = (GenerateTestYourselfViewModel)validationContext.ObjectInstance; if (model.Number < _number) { return(new ValidationResult(this.ErrorMessage)); } else { return(ValidationResult.Success); } }
public IActionResult Index(GenerateTestYourselfViewModel model) { //Use for Titile in html ViewData["Title"] = "Список категорий"; //Use for head in page ViewBag.HeadPageText = "Список категорий"; if (model != null) { if (ModelState.IsValid) { //return RedirectToAction("TestPage", "TestYourself", new { arrayOfNumbers = GetNumbers(model.Number) }); TempData["Temp"] = GetNumbers(model.Number); return(RedirectToAction("TestPage", "TestYourself")); } } return(View(model)); }