public ActionResult Create(UserModel user) { if (!ModelState.IsValid) { return View("new", user); } else { return RedirectToAction("Index"); } }
public ActionResult Index() { var users = _users.GetUsers(); var usersVM = new List<UserModel>(); foreach (var user in users) { var model = new UserModel {Age = user.Age, Id = user.Id, Name = user.Name}; usersVM.Add(model); } return View(usersVM); }
public ActionResult New() { var name = new UserModel(); return View(name); }
public ActionResult Index() { var name = new UserModel {Name = "Hugo"}; return View(name); }