private static Tuple<int, int> GetGradeAndClassFroUserDto(UserDto dto)
 {
     return Tuple.Create(dto.Grade, dto.ClassNumber);
 }
        public async Task<IHttpActionResult> UpdateUser(UserDto dto)
        {
            var user = await _identityReposiory.GetUserByIdAsync(dto.Id);
            if (user == null)
                return NotFound();
            if (dto.UserName != user.UserName && UserNameExists(dto.UserName))
            {
                return BadRequest("已存在此登录名");
            }
            user.UserName = dto.UserName;
            user.DisplayName = dto.DisplayName;
            user.IsEnabled = dto.IsEnabled;
            if (!(user.Grade == dto.Grade && user.Class == dto.ClassNumber))
                return BadRequest("不能更改用户的班级");

            var roles = dto.Roles.Distinct().Select(rs => _identityReposiory.GetAllRoles()
                .FirstOrDefault(r => r.Name == rs)).ToList();
            if (roles.Any(r => r == null))
                return BadRequest("用户角色不正确");
            await _identityReposiory.SaveUserAsync(user, roles);
            return StatusCode(HttpStatusCode.Accepted);
        }