public object Post(AssignRoles request)
        {
            request.UserName.ThrowIfNullOrEmpty();

            var userAuth = UserAuthRepo.GetUserAuthByUserName(request.UserName);

            if (userAuth == null)
            {
                throw HttpError.NotFound(request.UserName);
            }

            if (!request.Roles.IsEmpty())
            {
                foreach (var missingRole in request.Roles.Where(x => !userAuth.Roles.Contains(x)))
                {
                    userAuth.Roles.Add(missingRole);
                }
            }
            if (!request.Permissions.IsEmpty())
            {
                foreach (var missingPermission in request.Permissions.Where(x => !userAuth.Permissions.Contains(x)))
                {
                    userAuth.Permissions.Add(missingPermission);
                }
            }

            UserAuthRepo.SaveUserAuth(userAuth);

            return(new AssignRolesResponse {
                AllRoles = userAuth.Roles,
                AllPermissions = userAuth.Permissions,
            });
        }
        public object Post(AssignRoles request)
        {
            request.UserName.ThrowIfNullOrEmpty();

            var userAuth = UserAuthRepo.GetUserAuthByUserName(request.UserName);
            if (userAuth == null)
                throw HttpError.NotFound(request.UserName);

            if (!request.Roles.IsEmpty())
            {
                foreach (var missingRole in request.Roles.Where(x => !userAuth.Roles.Contains(x)))
                {
                    userAuth.Roles.Add(missingRole);
                }
            }
            if (!request.Permissions.IsEmpty())
            {
                foreach (var missingPermission in request.Permissions.Where(x => !userAuth.Permissions.Contains(x)))
                {
                    userAuth.Permissions.Add(missingPermission);
                }
            }

            UserAuthRepo.SaveUserAuth(userAuth);

            return new AssignRolesResponse {
                AllRoles = userAuth.Roles,
                AllPermissions = userAuth.Permissions,
            };
        }