public ActionResult Edit(HomeInputModel model,int id) { if(ModelState.IsValid) { _models.Remove(_models.Get(id)); model.Id = id; _models.Add(model); Success("The model was updated!"); return RedirectToAction("index"); } return View("Create", model); }
public ActionResult Create(HomeInputModel model) { if (ModelState.IsValid) { model.Id = _models.Count==0?1:_models.Select(x => x.Id).Max() + 1; _models.Add(model); Success("Your information was saved!"); return RedirectToAction("Index"); } Error("there were some errors in your form."); return View(model); }