public ActionResult Add(User u)
 {
     if (u != null)
     {
         if (iuser.InsertUser(u) == true)
         {
             if (Session["UserID"] == null)
             {
                 Session["UserID"]   = u.ID;
                 Session["UserName"] = u.UserName;
                 Session["Admin"]    = u.IsAdmin;
             }
             iuser.Commit();
         }
         else
         {
             ViewBag.DuplicateMessage = "username already exists";
             return(View(u));
         }
     }
     return(RedirectToAction("Index"));
 }
示例#2
0
        // [ValidateAntiForgeryToken]
        public ActionResult CreateUser(User user, string check)
        {
            if (check == "on")
            {
                user.Active = true;
            }
            else
            {
                user.Active = false;
            }



            if (user != null)
            {
                u.InsertUser(user);
                u.CommitUser();
                return(RedirectToAction("UserIndex"));
            }

            ViewBag.Type_id = new SelectList(t.GetTypes(), "Id", "type", user.Type_id);
            return(View(user));
        }