Example #1
0
        public bool AccquirePhysicianEvaluationLock(long eventCustomerId, long physicianId)
        {
            using (var adapter = PersistenceLayer.GetDataAccessAdapter())
            {
                var linqMetaData = new LinqMetaData(adapter);
                var ec           =
                    (from ecl in linqMetaData.EventCustomerEvaluationLock
                     where ecl.EventCustomerId == eventCustomerId
                     select ecl).SingleOrDefault();

                if (ec != null)
                {
                    if (ec.DateCreated > DateTime.Now.AddHours(-1))
                    {
                        return(false);
                    }

                    ReleasePhysicianEvaluationLock(eventCustomerId);
                }

                var eventCustomerEvaluationLockEntity = new EventCustomerEvaluationLockEntity()
                {
                    EventCustomerId = eventCustomerId,
                    PhysicianId     = physicianId,
                    DateCreated     = DateTime.Now
                };

                if (!adapter.SaveEntity(eventCustomerEvaluationLockEntity))
                {
                    throw new PersistenceFailureException();
                }
                return(true);
            }
        }
Example #2
0
        public bool ReleasePhysicianEvaluationLock(long eventCustomerId)
        {
            using (var adapter = PersistenceLayer.GetDataAccessAdapter())
            {
                var eventCustomerEvaluationLockEntity = new EventCustomerEvaluationLockEntity(eventCustomerId);

                if (!adapter.DeleteEntity(eventCustomerEvaluationLockEntity))
                {
                    throw new PersistenceFailureException();
                }
                return(true);
            }
        }