Example #1
0
        public async Task <JsonResult> SaveRole(Sys_Role role)
        {
            using (Sys_RoleRepository rep = new Sys_RoleRepository())
            {
                var result = await rep.AddOrUpdateAsync(role);

                return(Json(new { isOk = result }));
            }
        }
Example #2
0
        public async Task <JsonResult> GetlistAll()
        {
            using (Sys_RoleRepository rep = new Sys_RoleRepository())
            {
                var result = await rep.GetListAsync();

                return(Json(result));
            }
        }
Example #3
0
        public async Task <JsonResult> GetList(int rows, int page, string roleName)
        {
            using (Sys_RoleRepository rep = new Sys_RoleRepository())
            {
                var result = await rep.GetListAsync(page, rows, roleName);

                return(Json(new { total = result.Item1, rows = result.Item2 }));
            }
        }
Example #4
0
 public async Task <ActionResult> EditRole(int rid)
 {
     using (Sys_RoleRepository rep = new Sys_RoleRepository())
     {
         var role = new Sys_Role();
         if (rid > 0)
         {
             role = await rep.GetRoleAsync(rid);
         }
         return(View(role));
     }
 }
Example #5
0
        public async Task <JsonResult> DelRole(int rid)
        {
            using (Sys_RoleRepository rep = new Sys_RoleRepository())
            {
                using (Sys_UserRepository userRepo = new Sys_UserRepository())
                {
                    var userTotal = await userRepo.GetUserListCountByRoleID(rid);

                    if (userTotal > 0)
                    {
                        return(Json(new { isOk = false, msg = "请先删除该角色下的用户" }));
                    }
                    var result = await rep.DeleteRoleAsync(rid);

                    return(Json(new { isOk = result }));
                }
            }
        }
Example #6
0
 public override void SetCurrentRepository()
 {
     CurrentRepository = new Sys_RoleRepository();
 }
Example #7
0
 public Sys_RoleService(Sys_RoleRepository repository)
 {
     this.repository = repository;
 }