Exemplo n.º 1
0
            protected override async Task PerformOperation(Domain.Models.File file)
            {
                var isAdmin = await _identityResolver.IsAdminAsync();

                var userId             = _user.GetId();
                var isNotAlreadyLocked = (userId != file.LockedById);

                if (isNotAlreadyLocked)
                {
                    file.Lock(userId, isAdmin);
                }

                try
                {
                    file.Name = _request.Name;
                    file.Save(userId, isAdmin);
                }
                finally
                {
                    if (isNotAlreadyLocked)
                    {
                        file.Unlock(userId);
                    }
                }
            }
Exemplo n.º 2
0
            protected override async Task PerformOperation(Domain.Models.File file)
            {
                var isAdmin = await _identityResolver.IsAdminAsync();

                var userId             = _user.GetId();
                var isNotAlreadyLocked = (userId != file.LockedById);

                if (isNotAlreadyLocked)
                {
                    try
                    {
                        file.Lock(userId, isAdmin);
                    }
                    catch (FileConflictException)
                    {
                        throw new FileConflictException("Cannot rename a file while it's being edited or locked by another user.");
                    }
                }

                try
                {
                    file.Name = _request.Name;
                    file.Save(userId, isAdmin);
                }
                finally
                {
                    if (isNotAlreadyLocked)
                    {
                        file.Unlock(userId);
                    }
                }
            }
Exemplo n.º 3
0
            protected override async Task PerformOperation(Domain.Models.File file)
            {
                var isAdmin = await _identityResolver.IsAdminAsync();

                var userId = _user.GetId();

                file.Lock(userId, isAdmin);

                try
                {
                    file.Delete(isAdmin);
                }
                finally
                {
                    file.Unlock(userId);
                }
            }
Exemplo n.º 4
0
 protected override async Task PerformOperation(Domain.Models.File file)
 {
     file.Lock(_user.GetId(), isAdmin: (await _identityResolver.IsAdminAsync()));
 }