<repo_name>Nordcoder0101/FirstFormValidation<file_sep>/Controllers/HomeController.cs
﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using FirstFormValidation.Models;

namespace FirstFormValidation
{
  public class FirstFormValidationController : Controller
  {
    [HttpGet]
    [Route("")]
    public ViewResult Index()
    {

      return View();
    }
    [HttpGet]
    [Route("show")]
    public ViewResult Result(Survey survey)
    {

      return View(survey);
    }


    [HttpPost]
    [Route("post")]
    public IActionResult Post(Survey survey)
    {
        if(ModelState.IsValid)
        {
            return RedirectToAction("Result", survey);
        }
        else
        {
            return View("Index");
        }
      

      
    }
  }
}<file_sep>/Models/Survey.cs
using System.ComponentModel.DataAnnotations;
namespace FirstFormValidation.Models
{
  public class Survey
  {
    [Required]
    [MinLength(2)]
    public string Name { get; set; }
    [Required]
    public string Dojo { get; set; }
    [Required]
    public string Language { get; set; }

    [MaxLength(20)]
    public string Comment { get; set; }

    // public Survey(string name, string dojo, string language)
    // {
    //   Name = name;
    //   Dojo = dojo;
    //   Language = language;

    // }
    // public Survey(string name, string dojo, string language, string comment)
    // {
    //   Name = name;
    //   Dojo = dojo;
    //   Language = language;
    //   Comment = comment;
    // }
  }
}