예제 #1
0
        public bool OnPreDelete(PreDeleteEvent @event)
        {
            var seatArrangement = default(SeatArrangement);

            if (@event.TryCatchEntity(ref seatArrangement))
            {
                //seatArrangement.Cancel(null);
                //_occupationRepository.DeleteSeatArrangements(seatArrangement..Id);
           }
            return false;
        }
예제 #2
0
        public bool OnPreDelete(PreDeleteEvent @event)
        {
            if (IsEnabled)
            {
                var entity = default(Term);
                if (@event.TryCatchEntity(ref entity))
                {
                    if (DeleteSession == null)
                        DeleteSession = @event.Persister.Factory.GetCurrentSession();

                    var employeeId = entity.GetSnapshotValue<Guid>("EmployeeId");
                    var key = string.Format("{0}{1}", employeeId, entity.Start.Date);

                    if (!SqlCaches.ContainsKey(key))
                    {
                        var sql = string.Format("delete BackupTerm where BackupTerm.EmployeeId ='{0}' and datediff(d,starttime,'{1:yyyy/MM/dd HH:mm}')=0", employeeId, entity.Start.Date);
                        SqlCaches[key] = sql;
                        DeleteSession.CreateSQLQuery(sql).ExecuteUpdate();
                    }
                }
            }
            return false;
        }