コード例 #1
0
        public ViewResult FarenheitToCelsius(FarCelViewModel model)
        {
            try
            {
                Farenheit2Celsius temperature = new Farenheit2Celsius();
                model.Result = temperature.Convert(model.Choice, model.Temperature);
                ModelState.Clear();

                return(View(model));
            }
            catch (InvalidCastException ex)
            {
                return(View("Error", new HandleErrorInfo(ex, "Converter", "Error")));
            }
            //This catch block will catch other types of unhandled exceptions
            catch (Exception ex)
            {
                return(View("Error", new HandleErrorInfo(ex, "Converter", "Error")));
            }

            //return View();  //Calls view=ActionMethod name by default
            //return View("myViewName"); //Calls "MyViewName" regardless
            //return View("myViewName", MyViewModel);  //Calls another view
            //return View(myViewModel); //Calls view=ActionMethod with another model
        }
コード例 #2
0
        // GET: Farenheit / Celsius
        public ActionResult FarenheitToCelsius()
        {
            FarCelViewModel model = new FarCelViewModel();

            return(View(model));
        }