Exemplo n.º 1
0
        public Task InvokeUserDeleteAsync(Authentication authentication, UserDeleteArguments args)
        {
            var context    = this.Context;
            var repository = this.Repository;
            var message    = EventMessageBuilder.DeleteUser(authentication, args.UserID);

            return(repository.Dispatcher.InvokeAsync(() =>
            {
                using var locker = new RepositoryHostLock(repository, authentication, this, nameof(InvokeUserDeleteAsync), args.LockPaths);
                try
                {
                    var userSet = args.Read(authentication, repository);
                    var userContextSet = new UserContextSet(context, userSet, false);
                    repository.DeleteUser(userContextSet, args.UserPath);
                    repository.Commit(authentication, message);
                }
                catch
                {
                    repository.Revert();
                    throw;
                }
            }));
        }
Exemplo n.º 2
0
        public Task InvokeCategoryCreateAsync(Authentication authentication, string categoryPath)
        {
            var context    = this.Context;
            var repository = this.Repository;
            var itemPaths  = new string[] { categoryPath };
            var message    = EventMessageBuilder.CreateUserCategory(authentication, categoryPath);

            return(repository.Dispatcher.InvokeAsync(() =>
            {
                using var locker = new RepositoryHostLock(repository, authentication, this, nameof(InvokeCategoryCreateAsync), itemPaths);
                try
                {
                    var userContextSet = UserContextSet.CreateEmpty(authentication, context, itemPaths);
                    repository.CreateUserCategory(categoryPath);
                    repository.Commit(authentication, message);
                }
                catch
                {
                    repository.Revert();
                    throw;
                }
            }));
        }
Exemplo n.º 3
0
        public Task <UserSerializationInfo> InvokeUserPasswordResetAsync(Authentication authentication, UserResetPasswordArguments args)
        {
            var context    = this.Context;
            var repository = this.Repository;
            var message    = EventMessageBuilder.ResetPassword(authentication, args.UserID, args.UserName);

            return(repository.Dispatcher.InvokeAsync(() =>
            {
                using var locker = new RepositoryHostLock(repository, authentication, this, nameof(InvokeUserPasswordSetAsync), args.LockPaths);
                try
                {
                    var userSet = args.Read(authentication, repository);
                    var userContextSet = new UserContextSet(context, userSet, false);
                    repository.ModifyUser(userContextSet, args.UserPath, args.Password);
                    repository.Commit(authentication, message);
                    return userContextSet.GetUserInfo(args.UserPath);
                }
                catch
                {
                    repository.Revert();
                    throw;
                }
            }));
        }
Exemplo n.º 4
0
        public Task <UserSerializationInfo> InvokeUserCreateAsync(Authentication authentication, UserCreateArguments args)
        {
            var context    = this.Context;
            var repository = this.Repository;
            var message    = EventMessageBuilder.CreateUser(authentication, args.UserPaths, args.UserNames);

            return(repository.Dispatcher.InvokeAsync(() =>
            {
                using var locker = new RepositoryHostLock(repository, authentication, this, nameof(InvokeUserMoveAsync), args.LockPaths);
                try
                {
                    var userSet = args.Create(authentication);
                    var userContextSet = new UserContextSet(context, userSet, true);
                    repository.CreateUser(userContextSet, args.UserPaths);
                    repository.Commit(authentication, message);
                    return userContextSet.GetUserInfo(args.UserPath);
                }
                catch
                {
                    repository.Revert();
                    throw;
                }
            }));
        }