예제 #1
0
 public ActionResult SetAdminStatus(int userId,bool status)
 {
     if (adminMgt == null)
     {
         adminMgt = new AdministratorManagement(User.Identity.GetUserId<int>());
     }
     if (!adminMgt.CurrentLoginUser.IsSuperAdmin && !adminMgt.CurrentLoginUser.IsWebMaster)
     {
         ViewBag.Message = "只有超级管理员和站长才能禁用管理员";
         return View("Error");
     }
     adminMgt.SetAdminStatus(userId, status);
     return Redirect("/Admin/Administrators");
 }
예제 #2
0
 public ActionResult CreateAdmin()
 {
     if (adminMgt == null)
     {
         adminMgt = new AdministratorManagement(User.Identity.GetUserId<int>());
     }
     if (!adminMgt.CurrentLoginUser.IsSuperAdmin && !adminMgt.CurrentLoginUser.IsWebMaster)
     {
         ViewBag.Message = "只有超级管理员和站长才能新建管理员";
         return View("Error");
     }
     return View();
 }
예제 #3
0
        public async Task<ActionResult> CreateAdmin(CreateAdminModel model)
        {
            if(adminMgt==null)
            {
                adminMgt = new AdministratorManagement(User.Identity.GetUserId<int>());
            }
            if (!adminMgt.CurrentLoginUser.IsSuperAdmin && !adminMgt.CurrentLoginUser.IsWebMaster)
            {
                ViewBag.Message = "只有超级管理员和站长才能新建管理员";
                return View("Error");
            }
            if (ModelState.IsValid)
            {
                KMBit.DAL.Users newUser = new DAL.Users() { Enabled = true, Email = model.Email, Name = model.Name, PasswordHash = "123456789" };
                newUser = await adminMgt.CreateAdministrator(newUser);
                if(newUser.Id>0)
                {
                    return Redirect("/Admin/Administrators");
                }
            }

            return View(model);
        }
예제 #4
0
 public ActionResult Administrators()
 {
     if (adminMgt == null)
     {
         adminMgt = new AdministratorManagement(User.Identity.GetUserId<int>());
     }
     
     if (!adminMgt.CurrentLoginUser.IsSuperAdmin && !adminMgt.CurrentLoginUser.IsWebMaster)
     {
         ViewBag.Message = "只有超级管理员和站长可以查看管理员";
         return View("Error");
     }
     ViewBag.LoginUser = adminMgt.CurrentLoginUser;
     return View(adminMgt.FindAdministrators());
 }