示例#1
0
        public ActionResult Create(User user)
        {
            DataContext _db = new DataContext();
            if (ModelState.IsValid)
            {
                try
                {
                    _db.Users.Add(user);
                    _db.SaveChanges();

                }
                catch (Exception ex)
                {
                    ModelState.AddModelError(string.Empty, ex);
                }
            }
            return RedirectToAction("Create");
        }
示例#2
0
 public ActionResult GetUsers()
 {
     DataContext _db = new DataContext();
     var res = _db.Users;
     return View(res);
 }