Esempio n. 1
0
 public ActionResult ExerciseResult(ExerciseViewModel e) // , string operation
 {
     Exercise ex = e.exercise;
     int? f = ex.First;
     int? s = ex.Second;
     // int result;
     switch (e.Operation)
     {
         case "Add":
             e.Result = f + s;
             break;
         case "Subtract":
             e.Result = f - s;
             break;
         case "Mul":
             e.Result = f * s;
             break;
         case "Div":
             e.Result = f / s;
             break;
         default:
             return null;
     }
     // ViewBag.Result = result;
     // ViewBag.Operation = operation;
     return View("ShowExercise", e);
 }
Esempio n. 2
0
 public ActionResult ShowExercise(string operation)
 {
     // ViewBag.Operation = operation;
     Exercise e = new Exercise();
     ExerciseViewModel ex = new ExerciseViewModel();
     ex.exercise = e;
     ex.Operation = operation;
     return View(ex);
 }
Esempio n. 3
0
 public ActionResult ExerciseResult(ExerciseViewModel e) // , string operation
 {
     // int result;
     switch (e.Operation)
     {
         case "Add":
             e.Result = e.First + e.Second;
             break;
         case "Subtract":
             e.Result = e.First - e.Second;
             break;
         case "Mul":
             e.Result = e.First * e.Second;
             break;
         case "Div":
             e.Result = e.First / e.Second;
             break;
         default:
             return null;
     }
     // ViewBag.Result = result;
     // ViewBag.Operation = operation;
     return View("ShowExercise", e);
 }