public IActionResult Index() { CandyModel model = new CandyModel(); model.CandyList = _CandyRepo.GetList(); return(View(model)); }
public IActionResult Create(CandyModel model) { Candy candy = new Candy(); candy.productName = model.CandyName; _CandyRepo.Insert(candy); return(RedirectToAction("Index")); }
public IActionResult Index() { CandyModel model = new CandyModel { CandyList = new List <Candy>(_candyRepo.GetList()) }; return(View(model)); }
public IActionResult Index(CandyModel model) { if (!ModelState.IsValid) { return(View(model)); } _candyRepo.Insert(model.ProductName); return(RedirectToAction("Index")); }
public IActionResult Delete(CandyModel model) { int id = -1; var repo = new CandyDBRepository(); foreach (var candy in repo.GetList()) { if (candy.ProductName == model.ProductName) { id = candy.Id; break; } } if (id != -1) { repo.Delete(id); } return(RedirectToAction("Index")); }
public IActionResult Insert(CandyModel model) { new CandyDBRepository().Insert(model.ProductName); return(RedirectToAction("Index")); }