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); } }
public bool ReleasePhysicianEvaluationLock(long eventCustomerId) { using (var adapter = PersistenceLayer.GetDataAccessAdapter()) { var eventCustomerEvaluationLockEntity = new EventCustomerEvaluationLockEntity(eventCustomerId); if (!adapter.DeleteEntity(eventCustomerEvaluationLockEntity)) { throw new PersistenceFailureException(); } return(true); } }