Beispiel #1
0
 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);
 }
Beispiel #2
0
 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("保存成功!");
         return RedirectToAction("Index");
     }
     Error("表单中存在一些错误.");
     return View(model);
 }