Beispiel #1
0
        public ActionResult Create([Bind(Include = "FirstName,Surname,DOB,FirstLineAddress,SecondLineAddress,PostCode,Active")] User user)
        {
            if (ModelState.IsValid)
            {
                db.InsertUser(user);
                db.Save();
                return(RedirectToAction("Index"));
            }

            return(View(user));
        }
       // [Authorize]
        public ActionResult Create([Bind(Include = "UserID,FirstName,Surname,DOB,FirstLineAddress,SecondLineAddress,PostCode,Active,Deleted")] User user)
        {
           
            if (ModelState.IsValid)
            {
                try
                {
                db.InsertUser(user);
                db.Save();
                return RedirectToAction("Index");
                }
                catch (Exception ex) // catches all exceptions
                {
                    return View(ex.Message);
                }
            }
            ModelState.AddModelError("", "Error");
   

            return View(user);
        }