Exemplo n.º 1
0
        public async Task <bool> DeleteAsync(RepositoryUser record, ISecurityContext context)
        {
            Ensure.NotNull(record, nameof(record));
            Ensure.NotNull(context, nameof(context));

            var result = await db.RepositoryUsers.PatchAsync((record.RepositoryId, record.UserId), new[] {
                Change.Replace("deleted", Func("NOW"))
            }, condition : IsNull("deleted")) > 0;

            if (result)
            {
                await eventLog.CreateAsync(new Event("delete", $"borg:repository/{record.RepositoryId}/user/{record.UserId}"));
            }

            return(result);
        }
Exemplo n.º 2
0
        public async Task <RepositoryUser> CreateAsync(CreateRepositoryUserRequest request, ISecurityContext context)
        {
            Ensure.NotNull(request, nameof(request));
            Ensure.NotNull(context, nameof(context));

            var record = new RepositoryUser(
                repositoryId: request.RepositoryId,
                userId: request.UserId,
                privileges: request.Privileges,
                path: request.Path
                );

            await db.RepositoryUsers.InsertAsync(record);

            return(record);
        }