using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using FormValidation.Models;

namespace FormValidation.Controllers
{
    public class HomeController : Controller
    {
        public ActionResult Index()
        {
            return View();
        }

        [HttpPost]
        public ActionResult Index(Person person)
        {
            if (!string.IsNullOrEmpty(person.PostalCode) && !person.PostalCode.StartsWith("5"))
                ModelState.AddModelError("PostalCode", "Kod pocztowy nie jest z Wrocławia");
            // Oglądamy zawartość ModelState pod debuggerem
            if (ModelState.IsValid)
            {
            }
            else
            {
            }
            return View();
        }
    }
}
