I keep getting this error, and I don't know how to fix it:
CS0161:Home.Controller.Index(): not all code paths return a value
using Microsoft.AspNetCore.Mvc;
using TipCalculator.Models;
namespace TipCalculator.Controllers
{
public class HomeController : Controller
{
[HttpGet]
public IActionResult Index() // the Index is underline in red
{
ViewBag.Fifteen = 0;
ViewBag.Twenty = 0;
ViewBag.TwentyFive = 0;
View();
}
[HttpPost]
public IActionResult Index(Calculator calc)
{
if (ModelState.IsValid)
{
ViewBag.Fifteen = calc.CalculateTip(0.15);
ViewBag.Twenty = calc.CalculateTip(0.20);
ViewBag.TwentyFive = calc.CalculateTip(0.25);
}
else
{
ViewBag.Fifteen = 0;
ViewBag.Twenty = 0;
ViewBag.TwentyFive = 0;
}
return View(calc);
}
}
}