Example #1
0
 public int addAdmin(tblAdmin admin)
 {
     if (adminDAL.getAdmin(admin.username) != null)
     {
         return 0;
     }
     else
     {
         return adminDAL.addAdmin(admin);
     }
 }
Example #2
0
 public tblAdmin loginIn(tblAdmin admin)
 {
     var mAdmin = adminDAL.getAdmin(admin.username);
     if (admin.password == mAdmin.password)
     {
         return mAdmin;
     }
     else
     {
         return null;
     }
 }
        public ActionResult Register(RegisterModel model)
        {
            if (ModelState.IsValid)
            {
                // Attempt to register the user
                try
                {
                    AdminBLL adminBLL = new AdminBLL();
                    tblAdmin admin = new tblAdmin() {
                        username = model.UserName,
                        password = model.Password
                    };
                    //admin.username = model.UserName;
                    //admin.password = model.Password;
                    int effectedRow = adminBLL.addAdmin(admin);
                    if (effectedRow == 1)
                    {
                        return RedirectToAction("index", "Home");
                    }
                    else
                    {
                        ModelState.AddModelError("", "注册失败,用户名已被占用");
                    }
                    //WebSecurity.CreateUserAndAccount(model.UserName, model.Password);
                    //WebSecurity.Login(model.UserName, model.Password);
                    //return RedirectToAction("Index", "Home");
                }
                catch (MembershipCreateUserException e)
                {
                    ModelState.AddModelError("", ErrorCodeToString(e.StatusCode));
                }
            }

            // If we got this far, something failed, redisplay form
            return View(model);
        }
Example #4
0
 public int addAdmin(tblAdmin admin)
 {
     tblAdmin mAdmin = dbModel.tblAdmin.Add(admin);
        int effectedRow = dbModel.SaveChanges();
        return effectedRow;
 }