Exemple #1
0
        /// <summary>
        ///     Called before deleting an enumeration of entities.
        /// </summary>
        /// <param name="entities">The entities.</param>
        /// <param name="state">The state passed between the before delete and after delete callbacks.</param>
        /// <returns>
        ///     True to cancel the delete operation; false otherwise.
        /// </returns>
        public bool OnBeforeDelete(IEnumerable <IEntity> entities, IDictionary <string, object> state)
        {
            foreach (Tenant tenant in entities.Select(entity => entity.As <Tenant>()).Where(tenant => tenant != null))
            {
                // Gather tenant details required OnAfterDelete
                _auditLogEventTarget.GatherAuditLogEntityDetailsForDelete(tenant, state);
            }

            return(false);
        }
Exemple #2
0
        public void TestOnDeleteTenant()
        {
            bool   success    = true;
            string tenantName = "Tenant" + Guid.NewGuid();

            var mockAuditLog = new Mock <IAuditLog>(MockBehavior.Strict);

            mockAuditLog.Setup(al => al.OnDeleteTenant(success, tenantName));

            var eventTarget = new AuditLogTenantEventTarget(mockAuditLog.Object);

            var tenant = new Tenant {
                Name = tenantName
            };

            IDictionary <string, object> state = new Dictionary <string, object>();

            eventTarget.GatherAuditLogEntityDetailsForDelete(tenant, state);
            eventTarget.WriteDeleteAuditLogEntries(success, tenant.Id, state);

            mockAuditLog.VerifyAll();
        }