/// <summary> /// Deletes a collection <see cref="IOrder"/> /// </summary> /// <param name="orders">The collection of <see cref="IOrder"/> to be deleted</param> /// <param name="raiseEvents">Optional boolean indicating whether or not to raise events</param> public void Delete(IEnumerable <IOrder> orders, bool raiseEvents = true) { var ordersArray = orders as IOrder[] ?? orders.ToArray(); if (raiseEvents) { Deleting.RaiseEvent(new DeleteEventArgs <IOrder>(ordersArray), this); } using (new WriteLock(Locker)) { var uow = UowProvider.GetUnitOfWork(); using (var repository = RepositoryFactory.CreateOrderRepository(uow)) { foreach (var order in ordersArray) { // delete the shipments DeleteShipments(order); repository.Delete(order); } uow.Commit(); } } if (raiseEvents) { Deleted.RaiseEvent(new DeleteEventArgs <IOrder>(ordersArray), this); } }
/// <summary> /// Deletes a collection of <see cref="IProductVariant"/> /// </summary> /// <param name="productVariantList">The collction of <see cref="IProductVariant"/> to be deleted</param> /// <param name="raiseEvents">Optional boolean indicating whether or not to raise events</param> public void Delete(IEnumerable <IProductVariant> productVariantList, bool raiseEvents = true) { var productVariants = productVariantList as IProductVariant[] ?? productVariantList.ToArray(); if (raiseEvents) { Deleting.RaiseEvent(new DeleteEventArgs <IProductVariant>(productVariants), this); } using (new WriteLock(Locker)) { var uow = _uowProvider.GetUnitOfWork(); using (var repository = _repositoryFactory.CreateProductVariantRepository(uow)) { foreach (var product in productVariants) { repository.Delete(product); } uow.Commit(); } } if (raiseEvents) { Deleted.RaiseEvent(new DeleteEventArgs <IProductVariant>(productVariants), this); } }
/// <summary> /// Deletes a collection <see cref="IInvoice"/> /// </summary> /// <param name="invoices">The collection of <see cref="IInvoice"/> to be deleted</param> /// <param name="raiseEvents">Optional boolean indicating whether or not to raise events</param> public void Delete(IEnumerable <IInvoice> invoices, bool raiseEvents = true) { var invoicesArray = invoices as IInvoice[] ?? invoices.ToArray(); if (raiseEvents) { Deleting.RaiseEvent(new DeleteEventArgs <IInvoice>(invoicesArray), this); } using (new WriteLock(Locker)) { var uow = _uowProvider.GetUnitOfWork(); using (var repository = _repositoryFactory.CreateInvoiceRepository(uow)) { foreach (var invoice in invoicesArray) { DeleteAppliedPayments(invoice); DeleteOrders(invoice); repository.Delete(invoice); } uow.Commit(); } } if (raiseEvents) { Deleted.RaiseEvent(new DeleteEventArgs <IInvoice>(invoicesArray), this); } }
/// <summary> /// Deletes a collection of <see cref="INotificationMethod"/> /// </summary> /// <param name="notificationMethods">The collection of <see cref="INotificationMethod"/> to be deleted</param> /// <param name="raiseEvents">Optional boolean indicating whether or not to raise events</param> public void Delete(IEnumerable <INotificationMethod> notificationMethods, bool raiseEvents = true) { var notificationMethodsArray = notificationMethods as INotificationMethod[] ?? notificationMethods.ToArray(); if (raiseEvents) { Deleting.RaiseEvent(new DeleteEventArgs <INotificationMethod>(notificationMethodsArray), this); } using (new WriteLock(Locker)) { var uow = _uowProvider.GetUnitOfWork(); using (var repository = _repositoryFactory.CreateNotificationMethodRepository(uow)) { foreach (var notificationMethod in notificationMethodsArray) { repository.Delete(notificationMethod); } uow.Commit(); } } if (raiseEvents) { Deleted.RaiseEvent(new DeleteEventArgs <INotificationMethod>(notificationMethodsArray), this); } }
/// <summary> /// Deletes a collection <see cref="IItemCache"/> objects /// </summary> /// <param name="itemCaches">Collection of <see cref="IItemCache"/> to delete</param> /// <param name="raiseEvents">Optional boolean indicating whether or not to raise events</param> public void Delete(IEnumerable <IItemCache> itemCaches, bool raiseEvents = true) { var caches = itemCaches as IItemCache[] ?? itemCaches.ToArray(); if (raiseEvents) { Deleting.RaiseEvent(new DeleteEventArgs <IItemCache>(caches), this); } using (new WriteLock(Locker)) { var uow = UowProvider.GetUnitOfWork(); using (var repository = RepositoryFactory.CreateItemCacheRepository(uow)) { foreach (var basket in caches) { repository.Delete(basket); } uow.Commit(); } } if (raiseEvents) { Deleted.RaiseEvent(new DeleteEventArgs <IItemCache>(caches), this); } }
/// <summary> /// Deletes a collection of <see cref="IDetachedContentType"/>. /// </summary> /// <param name="detachedContentTypes"> /// The collection to be deleted. /// </param> /// <param name="raiseEvents"> /// Optional boolean indicating whether or not to raise events. /// </param> internal void Delete(IEnumerable <IDetachedContentType> detachedContentTypes, bool raiseEvents = true) { var detachedContentArray = detachedContentTypes as IDetachedContentType[] ?? detachedContentTypes.ToArray(); if (!detachedContentArray.Any()) { return; } if (raiseEvents) { Deleting.RaiseEvent(new DeleteEventArgs <IDetachedContentType>(detachedContentArray), this); } using (new WriteLock(Locker)) { var uow = UowProvider.GetUnitOfWork(); using (var repository = RepositoryFactory.CreateDetachedContentTypeRepository(uow)) { foreach (var detachedContent in detachedContentArray) { repository.Delete(detachedContent); } uow.Commit(); } } if (raiseEvents) { Deleted.RaiseEvent(new DeleteEventArgs <IDetachedContentType>(detachedContentArray), this); } }
/// <summary> /// Deletes a collection of <see cref="IPaymentMethod"/> /// </summary> /// <param name="paymentMethods">The collection of <see cref="IPaymentMethod"/> to be deleted</param> /// <param name="raiseEvents">Optional boolean indicating whether or not to raise events</param> public void Delete(IEnumerable <IPaymentMethod> paymentMethods, bool raiseEvents = true) { var methods = paymentMethods as IPaymentMethod[] ?? paymentMethods.ToArray(); if (raiseEvents) { Deleting.RaiseEvent(new DeleteEventArgs <IPaymentMethod>(methods), this); } using (new WriteLock(Locker)) { var uow = UowProvider.GetUnitOfWork(); using (var repository = RepositoryFactory.CreatePaymentMethodRepository(uow)) { foreach (var method in methods) { repository.Delete(method); } uow.Commit(); } } if (raiseEvents) { Deleted.RaiseEvent(new DeleteEventArgs <IPaymentMethod>(methods), this); } }
/// <summary> /// Deletes a collection <see cref="ICustomer"/> objects /// </summary> /// <param name="customers">Collection of <see cref="ICustomer"/> to delete</param> /// <param name="raiseEvents">Optional boolean indicating whether or not to raise events</param> public void Delete(IEnumerable <ICustomer> customers, bool raiseEvents = true) { var customerArray = customers as ICustomer[] ?? customers.ToArray(); if (raiseEvents) { Deleting.RaiseEvent(new DeleteEventArgs <ICustomer>(customerArray), this); } customerArray.ForEach(DeleteInvoicesAndPayments); using (new WriteLock(Locker)) { var uow = _uowProvider.GetUnitOfWork(); using (var repository = _repositoryFactory.CreateCustomerRepository(uow)) { foreach (var customer in customerArray) { repository.Delete(customer); } uow.Commit(); } } if (raiseEvents) { Deleted.RaiseEvent(new DeleteEventArgs <ICustomer>(customerArray), this); } }
/// <summary> /// Deletes a collection <see cref="IWarehouse"/> objects /// </summary> /// <param name="warehouseList">Collection of <see cref="IWarehouse"/> to delete</param> /// <param name="raiseEvents">Optional boolean indicating whether or not to raise events</param> internal void Delete(IEnumerable <IWarehouse> warehouseList, bool raiseEvents = true) { var warehouseArray = warehouseList as IWarehouse[] ?? warehouseList.ToArray(); if (raiseEvents) { Deleting.RaiseEvent(new DeleteEventArgs <IWarehouse>(warehouseArray), this); } using (new WriteLock(Locker)) { var uow = UowProvider.GetUnitOfWork(); using (var repository = RepositoryFactory.CreateWarehouseRepository(uow)) { foreach (var warehouse in warehouseArray) { repository.Delete(warehouse); } uow.Commit(); } } if (raiseEvents) { Deleted.RaiseEvent(new DeleteEventArgs <IWarehouse>(warehouseArray), this); } }
/// <summary> /// Deletes a collection of <see cref="IShipment"/> objects /// </summary> /// <param name="shipmentList">Collection of <see cref="IShipment"/> to delete</param> /// <param name="raiseEvents">Optional boolean indicating whether or not to raise events</param> public void Delete(IEnumerable <IShipment> shipmentList, bool raiseEvents = true) { var shipmentsArray = shipmentList as IShipment[] ?? shipmentList.ToArray(); if (raiseEvents) { Deleting.RaiseEvent(new DeleteEventArgs <IShipment>(shipmentsArray), this); } using (new WriteLock(Locker)) { var uow = _uowProvider.GetUnitOfWork(); using (var repository = _repositoryFactory.CreateShipmentRepository(uow)) { foreach (var shipment in shipmentsArray) { UpdateOrderLineItemShipmentKeys(shipment); repository.Delete(shipment); } } uow.Commit(); } if (raiseEvents) { Deleted.RaiseEvent(new DeleteEventArgs <IShipment>(shipmentsArray), this); } }
/// <summary> /// Deletes a collection of <see cref="IDigitalMedia"/> from the database. /// </summary> /// <param name="digitalMedias"> /// The digital medias. /// </param> /// <param name="raiseEvents"> /// The raise events. /// </param> public void Delete(IEnumerable <IDigitalMedia> digitalMedias, bool raiseEvents = true) { var digitalMediaArray = digitalMedias as IDigitalMedia[] ?? digitalMedias.ToArray(); if (raiseEvents) { Deleting.RaiseEvent(new DeleteEventArgs <IDigitalMedia>(digitalMediaArray), this); } using (new WriteLock(Locker)) { var uow = UowProvider.GetUnitOfWork(); using (var repository = RepositoryFactory.CreateDigitalMediaRepository(uow)) { foreach (var digitalMedia in digitalMediaArray) { repository.Delete(digitalMedia); } uow.Commit(); } } if (raiseEvents) { Deleted.RaiseEvent(new DeleteEventArgs <IDigitalMedia>(digitalMediaArray), this); } }
/// <summary> /// Deletes a collection of <see cref="IGatewayProviderSettings"/> /// </summary> /// <param name="gatewayProviderList"></param> /// <param name="raiseEvents"></param> /// <remarks> /// Used for testing /// </remarks> internal void Delete(IEnumerable <IGatewayProviderSettings> gatewayProviderList, bool raiseEvents = true) { var gatewayProviderArray = gatewayProviderList as IGatewayProviderSettings[] ?? gatewayProviderList.ToArray(); if (raiseEvents) { Deleting.RaiseEvent(new DeleteEventArgs <IGatewayProviderSettings>(gatewayProviderArray), this); } using (new WriteLock(Locker)) { var uow = UowProvider.GetUnitOfWork(); using (var repository = RepositoryFactory.CreateGatewayProviderRepository(uow)) { foreach (var gatewayProvider in gatewayProviderArray) { repository.Delete(gatewayProvider); } uow.Commit(); } } if (raiseEvents) { Deleted.RaiseEvent(new DeleteEventArgs <IGatewayProviderSettings>(gatewayProviderArray), this); } }
/// <summary> /// Deletes a collection of <see cref="IPayment"/> /// </summary> /// <param name="payments"> /// The payments. /// </param> /// <param name="raiseEvents"> /// The raise events. /// </param> public void Delete(IEnumerable <IPayment> payments, bool raiseEvents = true) { var paymentsArray = payments as IPayment[] ?? payments.ToArray(); if (raiseEvents) { Deleting.RaiseEvent(new DeleteEventArgs <IPayment>(paymentsArray), this); } using (new WriteLock(Locker)) { var uow = UowProvider.GetUnitOfWork(); using (var repository = RepositoryFactory.CreatePaymentRepository(uow)) { foreach (var payment in paymentsArray) { repository.Delete(payment); } uow.Commit(); } } if (raiseEvents) { Deleted.RaiseEvent(new DeleteEventArgs <IPayment>(paymentsArray), this); } }
/// <summary> /// Deletes a collection of <see cref="IOfferSettings"/>. /// </summary> /// <param name="offersSettings"> /// The offers settings. /// </param> /// <param name="raiseEvents"> /// Optional boolean indicating whether or not to raise events /// </param> public void Delete(IEnumerable <IOfferSettings> offersSettings, bool raiseEvents = true) { var settingsArray = offersSettings as IOfferSettings[] ?? offersSettings.ToArray(); if (raiseEvents) { Deleting.RaiseEvent(new DeleteEventArgs <IOfferSettings>(settingsArray), this); } using (new WriteLock(Locker)) { var uow = UowProvider.GetUnitOfWork(); using (var repository = RepositoryFactory.CreateOfferSettingsRepository(uow)) { foreach (var setting in settingsArray) { repository.Delete(setting); } uow.Commit(); } } if (raiseEvents) { Deleted.RaiseEvent(new DeleteEventArgs <IOfferSettings>(settingsArray), this); } }
/// <summary> /// Deletes a collection of product options /// </summary> /// <param name="options"> /// The collection of product options to be deleted /// </param> /// <param name="raiseEvents"> /// Optional boolean indicating whether or not to raise events. /// </param> /// <remarks> /// This performs a check to ensure the option is valid to be deleted /// /// THIS is INTERNAL due to sharing policies /// /// </remarks> internal void Delete(IEnumerable <IProductOption> options, bool raiseEvents = true) { var optionsArray = options as IProductOption[] ?? options.ToArray(); if (raiseEvents) { Deleting.RaiseEvent(new DeleteEventArgs <IProductOption>(optionsArray), this); } using (new WriteLock(Locker)) { var uow = UowProvider.GetUnitOfWork(); using (var repository = RepositoryFactory.CreateProductOptionRepository(uow)) { foreach (var option in optionsArray) { repository.Delete(option); } uow.Commit(); } } if (raiseEvents) { Deleted.RaiseEvent(new DeleteEventArgs <IProductOption>(optionsArray), this); } }
/// <summary> /// Deletes a collection of <see cref="ICustomerAddress"/> /// </summary> /// <param name="addresses"> /// The addresses. /// </param> /// <param name="raiseEvents"> /// The raise events. /// </param> /// <remarks> /// TODO - come up with a validation strategy on batch saves that protects default address settings /// </remarks> internal void Delete(IEnumerable <ICustomerAddress> addresses, bool raiseEvents = true) { var addressArray = addresses as ICustomerAddress[] ?? addresses.ToArray(); if (raiseEvents) { Deleting.RaiseEvent(new DeleteEventArgs <ICustomerAddress>(addressArray), this); } using (new WriteLock(Locker)) { var uow = _uowProvider.GetUnitOfWork(); using (var repository = _repositoryFactory.CreateCustomerAddressRepository(uow)) { foreach (var address in addressArray) { repository.Delete(address); } uow.Commit(); } } if (raiseEvents) { Deleted.RaiseEvent(new DeleteEventArgs <ICustomerAddress>(addressArray), this); } }
/// <summary> /// The delete. /// </summary> /// <param name="redemptions"> /// The redemptions. /// </param> /// <param name="raiseEvents"> /// Optional boolean indicating whether or not to raise events /// </param> public void Delete(IEnumerable <IOfferRedeemed> redemptions, bool raiseEvents = true) { var redemptionsArray = redemptions as IOfferRedeemed[] ?? redemptions.ToArray(); if (raiseEvents) { Deleting.RaiseEvent(new DeleteEventArgs <IOfferRedeemed>(redemptionsArray), this); } using (new WriteLock(Locker)) { var uow = UowProvider.GetUnitOfWork(); using (var repository = RepositoryFactory.CreateOfferRedeemedRepository(uow)) { foreach (var redemption in redemptionsArray) { repository.Delete(redemption); } uow.Commit(); } } if (raiseEvents) { Deleted.RaiseEvent(new DeleteEventArgs <IOfferRedeemed>(redemptionsArray), this); } }
/// <summary> /// Deletes a <see cref="IGatewayProviderSettings"/> /// </summary> /// <param name="gatewayProviderSettings"></param> /// <param name="raiseEvents">Optional boolean indicating whether or not to raise events</param> public void Delete(IGatewayProviderSettings gatewayProviderSettings, bool raiseEvents = true) { if (raiseEvents) { Deleting.RaiseEvent(new DeleteEventArgs <IGatewayProviderSettings>(gatewayProviderSettings), this); } // delete associated methods switch (gatewayProviderSettings.GatewayProviderType) { case GatewayProviderType.Payment: var paymentMethods = _paymentMethodService.GetPaymentMethodsByProviderKey(gatewayProviderSettings.Key).ToArray(); if (paymentMethods.Any()) { _paymentMethodService.Delete(paymentMethods); } break; case GatewayProviderType.Shipping: var shippingMethods = _shipMethodService.GetShipMethodsByProviderKey(gatewayProviderSettings.Key).ToArray(); if (shippingMethods.Any()) { _shipMethodService.Delete(shippingMethods); } break; case GatewayProviderType.Taxation: var taxMethods = _taxMethodService.GetTaxMethodsByProviderKey(gatewayProviderSettings.Key).ToArray(); if (taxMethods.Any()) { _taxMethodService.Delete(taxMethods); } break; case GatewayProviderType.Notification: var notificationMethods = _notificationMethodService.GetNotifcationMethodsByProviderKey(gatewayProviderSettings.Key).ToArray(); if (notificationMethods.Any()) { _notificationMethodService.Delete(notificationMethods); } break; } using (new WriteLock(Locker)) { var uow = UowProvider.GetUnitOfWork(); using (var repository = RepositoryFactory.CreateGatewayProviderRepository(uow)) { repository.Delete(gatewayProviderSettings); uow.Commit(); } } if (raiseEvents) { Deleted.RaiseEvent(new DeleteEventArgs <IGatewayProviderSettings>(gatewayProviderSettings), this); } }
/// <summary> /// Deletes a single <see cref="IWarehouse"/> object /// </summary> /// <param name="warehouse">The <see cref="IWarehouse"/> to delete</param> /// <param name="raiseEvents">Optional boolean indicating whether or not to raise events</param> internal void Delete(IWarehouse warehouse, bool raiseEvents = true) { if (raiseEvents) { Deleting.RaiseEvent(new DeleteEventArgs <IWarehouse>(warehouse), this); } using (new WriteLock(Locker)) { var uow = UowProvider.GetUnitOfWork(); using (var repository = RepositoryFactory.CreateWarehouseRepository(uow)) { repository.Delete(warehouse); uow.Commit(); } } if (raiseEvents) { Deleted.RaiseEvent(new DeleteEventArgs <IWarehouse>(warehouse), this); } }
/// <summary> /// Deletes a single <see cref="IItemCache"/> object /// </summary> /// <param name="itemCache">The <see cref="IItemCache"/> to delete</param> /// <param name="raiseEvents">Optional boolean indicating whether or not to raise events</param> public void Delete(IItemCache itemCache, bool raiseEvents = true) { if (raiseEvents) { Deleting.RaiseEvent(new DeleteEventArgs <IItemCache>(itemCache), this); } using (new WriteLock(Locker)) { var uow = UowProvider.GetUnitOfWork(); using (var repository = RepositoryFactory.CreateItemCacheRepository(uow)) { repository.Delete(itemCache); uow.Commit(); } } if (raiseEvents) { Deleted.RaiseEvent(new DeleteEventArgs <IItemCache>(itemCache), this); } }
/// <summary> /// Deletes a single <see cref="ICustomer"/> object /// </summary> /// <param name="customer">The <see cref="ICustomer"/> to delete</param> /// <param name="raiseEvents">Optional boolean indicating whether or not to raise events</param> internal void Delete(ICustomer customer, bool raiseEvents = true) { if (raiseEvents) { Deleting.RaiseEvent(new DeleteEventArgs <ICustomer>(customer), this); } using (new WriteLock(Locker)) { var uow = _uowProvider.GetUnitOfWork(); using (var repository = _repositoryFactory.CreateCustomerRepository(uow)) { repository.Delete(customer); uow.Commit(); } } if (raiseEvents) { Deleted.RaiseEvent(new DeleteEventArgs <ICustomer>(customer), this); } }
/// <summary> /// Deletes a single <see cref="IDigitalMedia"/> from the database. /// </summary> /// <param name="digitalMedia"> /// The digital media. /// </param> /// <param name="raiseEvents"> /// Optional boolean indicating whether or not to raise events. /// </param> public void Delete(IDigitalMedia digitalMedia, bool raiseEvents = true) { if (raiseEvents) { Deleting.RaiseEvent(new DeleteEventArgs <IDigitalMedia>(digitalMedia), this); } using (new WriteLock(Locker)) { var uow = UowProvider.GetUnitOfWork(); using (var repository = RepositoryFactory.CreateDigitalMediaRepository(uow)) { repository.Delete(digitalMedia); uow.Commit(); } } if (raiseEvents) { Deleted.RaiseEvent(new DeleteEventArgs <IDigitalMedia>(digitalMedia), this); } }
/// <summary> /// Deletes a collection of <see cref="IWarehouseCatalog"/> /// </summary> /// <param name="warehouseCatalogs"> /// The warehouse catalogs. /// </param> /// <param name="raiseEvents"> /// The raise events. /// </param> public void Delete(IEnumerable <IWarehouseCatalog> warehouseCatalogs, bool raiseEvents = true) { var catalogs = warehouseCatalogs.Where(x => x.Key != Core.Constants.Warehouse.DefaultWarehouseCatalogKey).ToArray(); if (!catalogs.Any()) { return; } if (raiseEvents) { Deleting.RaiseEvent(new DeleteEventArgs <IWarehouseCatalog>(catalogs), this); } foreach (var catalog in catalogs) { RemoveVariantsFromCatalogInventoryBeforeDeleting(catalog); } using (new WriteLock(Locker)) { var uow = UowProvider.GetUnitOfWork(); using (var repository = RepositoryFactory.CreateWarehouseCatalogRepository(uow)) { foreach (var catalog in catalogs) { repository.Delete(catalog); } uow.Commit(); } } if (raiseEvents) { Deleted.RaiseEvent(new DeleteEventArgs <IWarehouseCatalog>(catalogs), this); } }
/// <summary> /// Deletes a single <see cref="ICustomerAddress"/> /// </summary> /// <param name="address"> /// The address. /// </param> /// <param name="raiseEvents"> /// The raise events. /// </param> public void Delete(ICustomerAddress address, bool raiseEvents = true) { if (raiseEvents) { Deleting.RaiseEvent(new DeleteEventArgs <ICustomerAddress>(address), this); } using (new WriteLock(Locker)) { var uow = _uowProvider.GetUnitOfWork(); using (var repository = _repositoryFactory.CreateCustomerAddressRepository(uow)) { repository.Delete(address); uow.Commit(); } } if (raiseEvents) { Deleted.RaiseEvent(new DeleteEventArgs <ICustomerAddress>(address), this); } // If we deleted the default address and there are other addresses of this type - pick one if (!address.IsDefault) { return; } var newDefault = GetByCustomerKey(address.CustomerKey, address.AddressType).FirstOrDefault(); if (newDefault == null) { return; } newDefault.IsDefault = true; Save(newDefault); }
/// <summary> /// Deletes a collection of <see cref="IAnonymousCustomer"/> /// </summary> /// <param name="anonymouses"> /// The anonymous customers to be deleted /// </param> public void Delete(IEnumerable <IAnonymousCustomer> anonymouses) { var anonymousArray = anonymouses as IAnonymousCustomer[] ?? anonymouses.ToArray(); Deleting.RaiseEvent(new DeleteEventArgs <IAnonymousCustomer>(anonymousArray), this); using (new WriteLock(Locker)) { var uow = UowProvider.GetUnitOfWork(); using (var repository = RepositoryFactory.CreateAnonymousCustomerRepository(uow)) { foreach (var anonymous in anonymousArray) { repository.Delete(anonymous); } uow.Commit(); } } Deleted.RaiseEvent(new DeleteEventArgs <IAnonymousCustomer>(anonymousArray), this); }
/// <summary> /// Deletes a collection of entity collections. /// </summary> /// <param name="entityCollections"> /// The entity collections. /// </param> /// <param name="raiseEvents"> /// Optional boolean indicating whether or not to raise events. /// </param> internal void Delete(IEnumerable <IEntityCollection> entityCollections, bool raiseEvents = true) { var collectionsArray = entityCollections as IEntityCollection[] ?? entityCollections.ToArray(); if (!collectionsArray.Any()) { return; } if (raiseEvents) { Deleting.RaiseEvent(new DeleteEventArgs <IEntityCollection>(collectionsArray), this); } foreach (var collection in collectionsArray) { this.DeleteAllChildCollections(collection); } using (new WriteLock(Locker)) { var uow = UowProvider.GetUnitOfWork(); using (var repository = RepositoryFactory.CreateEntityCollectionRepository(uow)) { foreach (var collection in collectionsArray) { repository.Delete(collection); } uow.Commit(); } } if (raiseEvents) { Deleted.RaiseEvent(new DeleteEventArgs <IEntityCollection>(collectionsArray), this); } }
/// <summary> /// Deletes a collection of <see cref="IAuditLog"/> /// </summary> /// <param name="auditLogs"> /// The collection of <see cref="IAuditLog"/>s to be deleted /// </param> /// <param name="raiseEvents"> /// Optional boolean indicating whether or not to raise events /// </param> public void Delete(IEnumerable <IAuditLog> auditLogs, bool raiseEvents = true) { var auditLogsArray = auditLogs as IAuditLog[] ?? auditLogs.ToArray(); if (raiseEvents) { Deleting.RaiseEvent(new DeleteEventArgs <IAuditLog>(auditLogsArray), this); } using (new WriteLock(Locker)) { var uow = UowProvider.GetUnitOfWork(); using (var repository = RepositoryFactory.CreateAuditLogRepository(uow)) { foreach (var auditLog in auditLogsArray) { repository.Delete(auditLog); } uow.Commit(); } } Deleted.RaiseEvent(new DeleteEventArgs <IAuditLog>(auditLogsArray), this); }
/// <summary> /// Deletes a collection of <see cref="INote"/> /// </summary> /// <param name="notes"> /// The collection of <see cref="INote"/>s to be deleted /// </param> /// <param name="raiseEvents"> /// Optional boolean indicating whether or not to raise events /// </param> public void Delete(IEnumerable <INote> notes, bool raiseEvents = true) { var notesArray = notes as INote[] ?? notes.ToArray(); if (raiseEvents) { Deleting.RaiseEvent(new DeleteEventArgs <INote>(notesArray), this); } using (new WriteLock(Locker)) { var uow = UowProvider.GetUnitOfWork(); using (var repository = RepositoryFactory.CreateNoteRepository(uow)) { foreach (var note in notesArray) { repository.Delete(note); } uow.Commit(); } } Deleted.RaiseEvent(new DeleteEventArgs <INote>(notesArray), this); }