Example #1
0
        public override bool LockObjects(ODataQueryOptions queryOptions, IEnumerable <DataObject> dataObjects)
        {
            var lockKeys = new List <object>();

            try
            {
                foreach (var dataObject in dataObjects)
                {
                    if (!IsLockingRequired(queryOptions, dataObject))
                    {
                        continue;
                    }

                    var lockData = _lockService.LockObject(dataObject.__PrimaryKey, _currentUser.Login);
                    if (!lockData.Acquired)
                    {
                        Unlock(lockKeys);
                        return(false);
                    }

                    lockKeys.Add(lockData.Key);
                }

                return(true);
            }
            catch (Exception)
            {
                Unlock(lockKeys);
            }

            return(false);
        }
 public LockData Lock(string dataObjectId)
 {
     return(_lockService.LockObject(dataObjectId, User.Identity.Name));
 }