public ActionResult ManyDeleted(string idsStr)
 {
     try
     {
         var ids = idsStr.Substring(0, idsStr.LastIndexOf(',')).Split(',');
         foreach (var id in ids)
         {
             AdminUserService.MarkDeleted(long.Parse(id));
         }
         return(Json(new AjaxResult <object>
         {
             code = 0,
             msg = "删除成功"
         }));
     }
     catch (Exception ex)
     {
         Log.ErrorFormat("批量删除失败:{0}", ex.Message);
         return(Json(new AjaxResult <object>
         {
             code = 1,
             msg = "删除失败"
         }));
     }
 }
Ejemplo n.º 2
0
 public ActionResult Delete(long id)
 {
     AdminUserService.MarkDeleted(id);
     return(Json(new AjaxResult {
         Status = "ok"
     }));
 }
Ejemplo n.º 3
0
        public void TestAddAdminUser()
        {
            long uid =
                userService.AddAdminUser("abc", "189181", "123", "*****@*****.**", null);
            var user = userService.GetById(uid);

            Assert.AreEqual(user.Name, "abc");
            Assert.AreEqual(user.PhoneNum, "189181");
            Assert.AreEqual(user.Email, "*****@*****.**");
            Assert.IsNull(user.CityId);
            Assert.IsTrue(userService.CheckLogin("189181", "123"));
            Assert.IsFalse(userService.CheckLogin("189181", "abc"));
            userService.GetAll();
            Assert.IsNotNull(userService.GetByPhoneNum("189181"));
            userService.MarkDeleted(uid);//为了保证TestCase可以重复执行,那么把创建的数据干掉
        }
Ejemplo n.º 4
0
 public static void CleanUp()
 {
     if (adminUserId != 0)
     {
         adminUserService.MarkDeleted(adminUserId);
     }
 }
Ejemplo n.º 5
0
 public static void CleanUp()
 {
     if (userId != 0)
     {
         userService.MarkDeleted(userId);
     }
 }
Ejemplo n.º 6
0
        public void TestAddAdminUser()
        {
            long userId   = service.AddAdminUser("hhz", "13680398478", "123", "*****@*****.**", null);
            var  userInfo = service.GetById(userId);

            Assert.AreEqual(userInfo.Name, "hhz");
            Assert.AreEqual(userInfo.PhoneNum, "13680398478");
            Assert.AreEqual(userInfo.Email, "*****@*****.**");
            Assert.IsNull(userInfo.CityId);
            Assert.IsTrue(service.CheckLogin("13680398478", "123"));
            Assert.IsFalse(service.CheckLogin("13680398478", "1242"));

            service.GetAll();
            Assert.IsNotNull(service.GetByPhoneNum("13680398478"));

            service.MarkDeleted(userId);
        }
Ejemplo n.º 7
0
 public ActionResult BatchDelete(long[] selectIds)
 {
     foreach (long id in selectIds)
     {
         AdminUserService.MarkDeleted(id);
     }
     return(Json(new AjaxResult {
         Status = "ok"
     }));
 }
Ejemplo n.º 8
0
 public JsonResult BatchDelete(long[] selectId)
 {
     foreach (var roleId in selectId)
     {
         AdminUserService.MarkDeleted(roleId);
     }
     return(Json(new AjaxResult {
         Status = "ok"
     }));
 }
Ejemplo n.º 9
0
        public ActionResult Delete(int id)
        {
            var dto = AdminUserService.GetById(id);

            AdminUserService.MarkDeleted(id);

            AdminLogService.AddNew($"删除管理员【LoginName:{dto.LoginName},UserName:{dto.UserName},Id:{dto.Id}】");
            return(Json(new AjaxResult {
                Result = true, Msg = "删除成功"
            }));
        }
Ejemplo n.º 10
0
        public void TestAddAdminUser()
        {
            AdminUserService auService = new AdminUserService();
            long             id        = auService.AddAdminUser("wuhuajie", "12312312312", "123456", "*****@*****.**", null);

            try
            {
                AdminUserDTO userDto = auService.GetById(id);
                Assert.AreEqual(id, userDto.Id);
                Assert.AreEqual("wuhuajie", userDto.Name);
                Assert.AreEqual("12312312312", userDto.PhoneNum);
                Assert.AreEqual(CommonHelper.CalcMD5(userDto.PasswordSalt + "123456"), userDto.PasswordHash);
                Assert.AreEqual("*****@*****.**", userDto.EMail);

                AdminUserDTO[] userDtos = auService.GetAll();
                //AminUserDTO[] userDtos2 = auService.GetAll();
                Assert.IsNotNull(userDtos);
                AdminUserDTO userDto2 = auService.GetByPhoneNum("12312312312");
                Assert.IsNotNull(userDto2);
                AdminUserDTO userDto3 = auService.GetByPhoneNum("1231231221312");
                Assert.IsNull(userDto3);
                bool login = auService.CheckLogin("12312312312", "123456");
                Assert.IsTrue(login);
                bool login2 = auService.CheckLogin("123412312312", "123456");
                Assert.IsFalse(login2);
                bool login3 = auService.CheckLogin("12312312312", "3422");
                Assert.IsFalse(login3);
                bool login4 = auService.CheckLogin("3242323423", "3422");
                Assert.IsFalse(login4);

                auService.MarkDeleted(id);
            }
            catch (Exception ex)
            {
                auService.MarkDeleted(id);
                throw ex;
            }
        }
Ejemplo n.º 11
0
 public ActionResult Delete(long id)
 {
     if (AdminUserService.MarkDeleted(id))
     {
         return(Json(new AjaxResult {
             Status = "ok"
         }));
     }
     else
     {
         return(Json(new AjaxResult {
             Status = "error"
         }));
     }
 }
Ejemplo n.º 12
0
 public void TestAdminUser()
 {
     long id = userService.AddAdminUser("abc", "13132131131", "123456", "*****@*****.**", null);
     var user= userService.GetById(id);
     Assert.AreEqual(user.Name, "abc");
     Assert.AreEqual(user.PhoneNum, "13132131131");
     Assert.AreEqual(user.Email, "*****@*****.**");
     Assert.IsNull(user.CityId);
     Assert.IsTrue(userService.CheckLogin("13132131131", "123456"));
     Assert.IsFalse(userService.CheckLogin("13132131131", "324"));
     userService.GetAll();
     Assert.IsNull(userService.GetByPhoneNum("2325252"));
     userService.GetAll(1);
     userService.UpdateAdminUser(id, "bbc", "*****@*****.**", null);
     userService.MarkDeleted(id);
 }
Ejemplo n.º 13
0
        public void AddAdminUserTest()
        {
            AdminUserService adminService = new AdminUserService();

            long id   = new AdminUserService().AddAdminUser("cyq", "189", "mima", "123", null);
            var  user = adminService.GetById(id);

            Assert.AreEqual("cyq", user.Name);
            Assert.AreEqual("189", user.PhoneNum);
            Assert.AreEqual("123", user.Email);
            Assert.IsTrue(adminService.CheckLogin("189", "mima"));
            Assert.IsFalse(adminService.CheckLogin("189", "mima1"));
            adminService.GetAll();
            Assert.IsNotNull(adminService.GetByPhoneNum("189"));
            adminService.MarkDeleted(id);
        }
Ejemplo n.º 14
0
        public void TestAddAdminUser()
        {
            string phoneNum = Guid.NewGuid().ToString().Substring(0, 11);
            long   uId      = adminUserService.AddAdminUser("张三", phoneNum, "123456", "*****@*****.**", null);
            var    user     = adminUserService.GetById(uId);

            Assert.AreEqual(user.Name, "张三");
            Assert.AreEqual(user.PhoneNum, phoneNum);
            Assert.AreEqual(user.Email, "*****@*****.**");
            Assert.IsNull(user.CityId);
            Assert.IsTrue(adminUserService.CheckLogin(phoneNum, "123456"));
            Assert.IsFalse(adminUserService.CheckLogin(phoneNum, "123"));
            adminUserService.GetAll();
            Assert.IsNotNull(adminUserService.GetByPhoneNum(phoneNum));
            adminUserService.MarkDeleted(uId);
        }
Ejemplo n.º 15
0
        public void PermissionTest()
        {
            PermissionService permService = new PermissionService();
            AdminUserService  userService = new AdminUserService();
            RoleService       roleService = new RoleService();
            string            roleName1   = Guid.NewGuid().ToString();
            string            permName1   = Guid.NewGuid().ToString();
            long   roleId1   = roleService.AddNew(roleName1);
            long   permId    = permService.AddPermission(permName1, permName1);
            string userPhone = "139138";
            long   userId    = userService.AddAdminUser("Aaa", userPhone, "mima", "email", null);

            roleService.AddRoleIds(userId, new long[] { roleId1 });
            permService.AddPermIds(roleId1, new long[] { permId });
            Assert.IsTrue(userService.HasPermission(userId, permName1));
            Assert.IsFalse(userService.HasPermission(userId, "1"));
            userService.MarkDeleted(userId);
        }
Ejemplo n.º 16
0
 public ActionResult Deleted(long id)
 {
     try
     {
         AdminUserService.MarkDeleted(id);
         return(Json(new AjaxResult <object>
         {
             code = 0,
             msg = "删除成功"
         }));
     }
     catch (Exception ex)
     {
         Log.ErrorFormat("删除失败:{0}", ex.Message);
         return(Json(new AjaxResult <object>
         {
             code = 1,
             msg = "删除失败"
         }));
     }
 }