Esempio n. 1
0
 public ActionResult Create(UserModel user)
 {
     if (!ModelState.IsValid)
     {
         return View("new", user);
     }
     else
     {
         return RedirectToAction("Index");
     }
 }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
 public ActionResult New()
 {
     var name = new UserModel();
     return View(name);
 }
Esempio n. 4
0
        public ActionResult Index()
        {
            var name = new UserModel {Name = "Hugo"};

            return View(name);
        }