public IActionResult Calculator() { var calc = new CalculatorVals() { FirstValue = 0, SecondValue = 0, Answer = 0, Operator = "+" }; return(View(calc)); }
public IActionResult Calculator(CalculatorVals vals) { if (vals.Operator == "+") { vals.Answer = vals.FirstValue + vals.SecondValue; } else if (vals.Operator == "-") { vals.Answer = vals.FirstValue - vals.SecondValue; } else if (vals.Operator == "/") { vals.Answer = vals.FirstValue / vals.SecondValue; } else { vals.Answer = vals.FirstValue * vals.SecondValue; } return(View(vals)); }