using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace MvcAvecTests.Controllers {
  public class CalculatriceController : Controller {
    public ActionResult Index() {
      return View();
    }
    [HttpGet]
    public ActionResult Additionner() {
      return RedirectToAction( "Index" );
    }
    [HttpPost]
    public ActionResult Additionner( string n1, string n2 ) {
      try {
        int i1 = int.Parse( n1 );
        int i2 = int.Parse( n2 );
        ViewBag.Resultat = checked( i1 + i2 );
      }
      catch( Exception erreur ) {
        ViewBag.Resultat = $"Erreur {erreur.GetType().Name} : {erreur.Message}";
        //ViewBag.Resultat = 0;
      }
      return View( "Index" );
    }
  }
}