public ActionResult ModelStateTestPost(int?id, ValidationMaxModel inputModel)
        {
            bool isValid;

            if (!id.HasValue)
            {
                return(RedirectToAction("Index"));
            }

            isValid = this.ModelState.IsValid; // = false

            this.ModelState.Clear();

            var model = ValidationMaxModel.GetModell(id.Value);

            inputModel.LastPurchaseDate = model.LastPurchaseDate;

            //Exception-t generáló változat: this.ValidateModel(inputModel);
            if (this.TryValidateModel(inputModel))
            {
                //Igen mostmár valid.
                isValid = this.ModelState.IsValid; // = true
            }

            if (this.TryUpdateModel(model))
            {
                return(RedirectToAction("ModelStateTest"));
            }


            return(View(model));
        }
        public async Task <ValidationMaxModel> ModelStateTest(int?id)
        {
            if (!id.HasValue)
            {
                return(null);
            }

            var model = await ValidationMaxModel.GetModell(id.Value);

            this.HttpContext.Response.StatusCode = 201;
            return(model);
        }
        public async Task <ObjectResult> ModelStateTestPost([Required] int id, [FromBody] ValidationMaxModel inputModel)
        {
            this.ModelState.Clear();

            var model = await ValidationMaxModel.GetModell(id);

            inputModel.LastPurchaseDate = model.LastPurchaseDate;

            if (this.TryValidateModel(inputModel))
            {
                return(Ok(model));
            }

            if (await this.TryUpdateModelAsync(model))
            {
                return(Ok(model));
            }


            return(BadRequest(ModelState));
        }
 public ActionResult Index()
 {
     return(View(ValidationMaxModel.GetModell(1)));
 }
 public ActionResult ShowValid(int?id)
 {
     return(View(ValidationMaxModel.GetModell(id ?? 1)));
 }
 public ActionResult ModelStateTest(int?id)
 {
     return(View(ValidationMaxModel.GetModell(id ?? 1)));
 }