Beispiel #1
0
        /// <summary>
        /// Deletes a <see cref="IShipRateTier"/>
        /// </summary>
        /// <param name="shipRateTier">The <see cref="IShipRateTier"/> to be deleted</param>
        /// <param name="raiseEvents">Optional boolean indicating whether or not to raise events.</param>
        public void Delete(IShipRateTier shipRateTier, bool raiseEvents = true)
        {
            if (raiseEvents)
            {
                if (Deleting.IsRaisedEventCancelled(new DeleteEventArgs <IShipRateTier>(shipRateTier), this))
                {
                    ((ShipRateTier)shipRateTier).WasCancelled = true;
                    return;
                }
            }

            using (new WriteLock(Locker))
            {
                var uow = UowProvider.GetUnitOfWork();
                using (var repository = RepositoryFactory.CreateShipRateTierRepository(uow))
                {
                    repository.Delete(shipRateTier);
                    uow.Commit();
                }
            }

            if (raiseEvents)
            {
                Deleted.RaiseEvent(new DeleteEventArgs <IShipRateTier>(shipRateTier), this);
            }
        }
Beispiel #2
0
        /// <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);
            }
        }
Beispiel #3
0
        /// <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);
            }
        }
Beispiel #4
0
        /// <summary>
        /// Deletes a single <see cref="IPaymentMethod"/>
        /// </summary>
        /// <param name="paymentMethod">The <see cref="IPaymentMethod"/> to be deleted</param>
        /// <param name="raiseEvents">Optional boolean indicating whether or not to raise events</param>
        public void Delete(IPaymentMethod paymentMethod, bool raiseEvents = true)
        {
            if (raiseEvents)
            {
                if (Deleting.IsRaisedEventCancelled(new DeleteEventArgs <IPaymentMethod>(paymentMethod), this))
                {
                    ((PaymentMethod)paymentMethod).WasCancelled = true;
                    return;
                }
            }

            using (new WriteLock(Locker))
            {
                var uow = UowProvider.GetUnitOfWork();
                using (var repository = RepositoryFactory.CreatePaymentMethodRepository(uow))
                {
                    repository.Delete(paymentMethod);
                    uow.Commit();
                }
            }

            if (raiseEvents)
            {
                Deleted.RaiseEvent(new DeleteEventArgs <IPaymentMethod>(paymentMethod), this);
            }
        }
Beispiel #5
0
        /// <summary>
        /// Deletes a single instance of a <see cref="IWarehouseCatalog"/>.
        /// </summary>
        /// <param name="warehouseCatalog">
        /// The warehouse catalog.
        /// </param>
        /// <param name="raiseEvents">
        /// The raise events.
        /// </param>
        public void Delete(IWarehouseCatalog warehouseCatalog, bool raiseEvents = true)
        {
            if (warehouseCatalog.Key == Core.Constants.Warehouse.DefaultWarehouseCatalogKey)
            {
                return;
            }

            if (raiseEvents)
            {
                if (Deleting.IsRaisedEventCancelled(new DeleteEventArgs <IWarehouseCatalog>(warehouseCatalog), this))
                {
                    ((WarehouseCatalog)warehouseCatalog).WasCancelled = true;
                    return;
                }
            }

            RemoveVariantsFromCatalogInventoryBeforeDeleting(warehouseCatalog);

            using (new WriteLock(Locker))
            {
                var uow = UowProvider.GetUnitOfWork();
                using (var repository = RepositoryFactory.CreateWarehouseCatalogRepository(uow))
                {
                    repository.Delete(warehouseCatalog);
                    uow.Commit();
                }
            }

            if (raiseEvents)
            {
                Deleted.RaiseEvent(new DeleteEventArgs <IWarehouseCatalog>(warehouseCatalog), this);
            }
        }
        /// <summary>
        /// Deletes a single instance of <see cref="INotificationMessage"/>
        /// </summary>
        /// <param name="notificationMessage">The <see cref="INotificationMessage"/> to be deleted</param>
        /// <param name="raiseEvents">Optional boolean indicating whether or not to raise events</param>
        public void Delete(INotificationMessage notificationMessage, bool raiseEvents = true)
        {
            if (raiseEvents)
            {
                if (Deleting.IsRaisedEventCancelled(new DeleteEventArgs <INotificationMessage>(notificationMessage), this))
                {
                    ((NotificationMessage)notificationMessage).WasCancelled = true;
                    return;
                }
            }

            using (new WriteLock(Locker))
            {
                var uow = _uowProvider.GetUnitOfWork();
                using (var repository = _repositoryFactory.CreateNotificationMessageRepository(uow))
                {
                    repository.Delete(notificationMessage);
                    uow.Commit();
                }
            }

            if (raiseEvents)
            {
                Deleted.RaiseEvent(new DeleteEventArgs <INotificationMessage>(notificationMessage), this);
            }
        }
Beispiel #7
0
        /// <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 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="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);
            }
        }
Beispiel #10
0
        /// <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 product option
        /// </summary>
        /// <param name="option">
        /// The option 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
        /// </remarks>
        public void Delete(IProductOption option, bool raiseEvents = true)
        {
            if (!EnsureSafeOptionDelete(option))
            {
                MultiLogHelper.Warn <ProductOptionService>("A ProductOption delete attempt was aborted.  The option cannot be deleted due to it being shared with one or more products.");
                return;
            }

            if (raiseEvents)
            {
                if (Deleting.IsRaisedEventCancelled(new DeleteEventArgs <IProductOption>(option), this))
                {
                    ((ProductOption)option).WasCancelled = true;
                    return;
                }
            }

            using (new WriteLock(Locker))
            {
                var uow = UowProvider.GetUnitOfWork();
                using (var repository = RepositoryFactory.CreateProductOptionRepository(uow))
                {
                    repository.Delete(option);
                    uow.Commit();
                }
            }

            if (raiseEvents)
            {
                Deleted.RaiseEvent(new DeleteEventArgs <IProductOption>(option), this);
            }
        }
        public void Delete(IEnumerable <IMemberType> memberTypes, int userId = 0)
        {
            var asArray = memberTypes.ToArray();

            if (Deleting.IsRaisedEventCancelled(new DeleteEventArgs <IMemberType>(asArray), this))
            {
                return;
            }

            using (new WriteLock(Locker))
            {
                foreach (var contentType in asArray)
                {
                    _memberService.DeleteMembersOfType(contentType.Id);
                }

                var uow = UowProvider.GetUnitOfWork();
                using (var repository = RepositoryFactory.CreateMemberTypeRepository(uow))
                {
                    foreach (var memberType in asArray)
                    {
                        repository.Delete(memberType);
                    }

                    uow.Commit();

                    Deleted.RaiseEvent(new DeleteEventArgs <IMemberType>(asArray, false), this);
                }
            }
        }
Beispiel #13
0
        /// <summary>
        /// Deletes a single of <see cref="IOfferSettings"/>.
        /// </summary>
        /// <param name="offerSettings">
        /// The offer settings.
        /// </param>
        /// <param name="raiseEvents">
        /// Optional boolean indicating whether or not to raise events
        /// </param>
        public void Delete(IOfferSettings offerSettings, bool raiseEvents = true)
        {
            if (raiseEvents)
            {
                if (Deleting.IsRaisedEventCancelled(new DeleteEventArgs <IOfferSettings>(offerSettings), this))
                {
                    return;
                }
            }


            using (new WriteLock(Locker))
            {
                var uow = _uowProvider.GetUnitOfWork();
                using (var repository = _repositoryFactory.CreateOfferSettingsRepository(uow))
                {
                    repository.Delete(offerSettings);
                    uow.Commit();
                }
            }

            if (raiseEvents)
            {
                Deleted.RaiseEvent(new DeleteEventArgs <IOfferSettings>(offerSettings), this);
            }
        }
Beispiel #14
0
        /// <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);
            }
        }
Beispiel #15
0
        /// <summary>
        /// Deletes an <see cref="IOfferRedeemed"/>
        /// </summary>
        /// <param name="offerRedeemed">
        /// The offer redeemed.
        /// </param>
        /// <param name="raiseEvents">
        /// Optional boolean indicating whether or not to raise events
        /// </param>
        public void Delete(IOfferRedeemed offerRedeemed, bool raiseEvents = true)
        {
            if (raiseEvents)
            {
                if (Deleting.IsRaisedEventCancelled(new DeleteEventArgs <IOfferRedeemed>(offerRedeemed), this))
                {
                    ((OfferRedeemed)offerRedeemed).WasCancelled = true;
                    return;
                }
            }


            using (new WriteLock(Locker))
            {
                var uow = UowProvider.GetUnitOfWork();
                using (var repository = RepositoryFactory.CreateOfferRedeemedRepository(uow))
                {
                    repository.Delete(offerRedeemed);
                    uow.Commit();
                }
            }

            if (raiseEvents)
            {
                Deleted.RaiseEvent(new DeleteEventArgs <IOfferRedeemed>(offerRedeemed), this);
            }
        }
Beispiel #16
0
        /// <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);
            }
        }
Beispiel #17
0
        /// <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);
            }
        }
Beispiel #18
0
        /// <summary>
        /// Deletes a single <see cref="IOrder"/>
        /// </summary>
        /// <param name="order">The <see cref="IOrder"/> to be deleted</param>
        /// <param name="raiseEvents">Optional boolean indicating whether or not to raise events</param>
        public void Delete(IOrder order, bool raiseEvents = true)
        {
            if (raiseEvents)
            {
                if (Deleting.IsRaisedEventCancelled(new DeleteEventArgs <IOrder>(order), this))
                {
                    ((Order)order).WasCancelled = true;
                    return;
                }
            }

            // Delete any shipment records associated with this order
            DeleteShipments(order);

            using (new WriteLock(Locker))
            {
                var uow = UowProvider.GetUnitOfWork();
                using (var repository = RepositoryFactory.CreateOrderRepository(uow))
                {
                    repository.Delete(order);
                    uow.Commit();
                }
            }

            if (raiseEvents)
            {
                Deleted.RaiseEvent(new DeleteEventArgs <IOrder>(order), this);
            }
        }
Beispiel #19
0
        /// <summary>
        /// Deletes a single <see cref="IShipment"/> object
        /// </summary>
        /// <param name="shipment"><see cref="IShipment"/> to delete</param>
        /// <param name="raiseEvents">Optional boolean indicating whether or not to raise events</param>
        public void Delete(IShipment shipment, bool raiseEvents = true)
        {
            if (raiseEvents)
            {
                if (Deleting.IsRaisedEventCancelled(new DeleteEventArgs <IShipment>(shipment), this))
                {
                    ((Shipment)shipment).WasCancelled = true;
                    return;
                }
            }

            using (new WriteLock(Locker))
            {
                var uow = _uowProvider.GetUnitOfWork();
                using (var repository = _repositoryFactory.CreateShipmentRepository(uow))
                {
                    UpdateOrderLineItemShipmentKeys(shipment);
                    repository.Delete(shipment);
                    uow.Commit();
                }
            }

            if (raiseEvents)
            {
                Deleted.RaiseEvent(new DeleteEventArgs <IShipment>(shipment), this);
            }
        }
Beispiel #20
0
        /// <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);
            }
        }
Beispiel #21
0
        /// <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);
            }
        }
Beispiel #22
0
        /// <summary>
        /// Deletes a <see cref="IAppliedPayment"/>
        /// </summary>
        /// <param name="appliedPayment">The <see cref="IAppliedPayment"/> to be deleted</param>
        /// <param name="raiseEvents">Optional boolean indicating whether or not to raise events</param>
        public void Delete(IAppliedPayment appliedPayment, bool raiseEvents = true)
        {
            if (raiseEvents)
            {
                if (Deleting.IsRaisedEventCancelled(new DeleteEventArgs <IAppliedPayment>(appliedPayment), this))
                {
                    ((AppliedPayment)appliedPayment).WasCancelled = true;
                    return;
                }
            }

            using (new WriteLock(Locker))
            {
                var uow = UowProvider.GetUnitOfWork();
                using (var repository = RepositoryFactory.CreateAppliedPaymentRepository(uow))
                {
                    repository.Delete(appliedPayment);
                    uow.Commit();
                }
            }

            if (raiseEvents)
            {
                Deleted.RaiseEvent(new DeleteEventArgs <IAppliedPayment>(appliedPayment), this);
            }
        }
Beispiel #23
0
        /// <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);
            }
        }
Beispiel #24
0
        /// <summary>
        /// Deletes a single entity collection.
        /// </summary>
        /// <param name="entityCollection">
        /// The entity collection.
        /// </param>
        /// <param name="raiseEvents">
        /// Optional boolean indicating whether or not to raise events.
        /// </param>
        public void Delete(IEntityCollection entityCollection, bool raiseEvents = true)
        {
            if (raiseEvents)
            {
                if (Deleting.IsRaisedEventCancelled(new DeleteEventArgs <IEntityCollection>(entityCollection), this))
                {
                    ((EntityCollection)entityCollection).WasCancelled = true;
                    return;
                }
            }

            DeleteAllChildCollections(entityCollection);

            UpdateSiblingSortOrders(entityCollection);

            using (new WriteLock(Locker))
            {
                var uow = UowProvider.GetUnitOfWork();
                using (var repository = RepositoryFactory.CreateEntityCollectionRepository(uow))
                {
                    repository.Delete(entityCollection);
                    uow.Commit();
                }
            }

            if (raiseEvents)
            {
                Deleted.RaiseEvent(new DeleteEventArgs <IEntityCollection>(entityCollection), this);
            }
        }
Beispiel #25
0
        /// <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);
            }
        }
Beispiel #26
0
        /// <summary>
        /// Empties the Recycle Bin by deleting all <see cref="IMedia"/> that resides in the bin
        /// </summary>
        public void EmptyRecycleBin()
        {
            //TODO: Why don't we have a base class to share between MediaService/ContentService as some of this is exacty the same?

            var uow = _uowProvider.GetUnitOfWork();

            using (var repository = _repositoryFactory.CreateMediaRepository(uow))
            {
                var query = Query <IMedia> .Builder.Where(x => x.Trashed == true);

                var contents = repository.GetByQuery(query).OrderByDescending(x => x.Level);

                foreach (var content in contents)
                {
                    if (Deleting.IsRaisedEventCancelled(new DeleteEventArgs <IMedia>(content), this))
                    {
                        continue;
                    }

                    repository.Delete(content);

                    Deleted.RaiseEvent(new DeleteEventArgs <IMedia>(content, false), this);
                }
                uow.Commit();
            }

            Audit.Add(AuditTypes.Delete, "Empty Recycle Bin performed by user", 0, -20);
        }
Beispiel #27
0
        /// <summary>
        /// Deletes a single <see cref="IProductVariant"/>
        /// </summary>
        /// <param name="productVariant">The <see cref="IProductVariant"/> to be deleted</param>
        /// <param name="raiseEvents">Optional boolean indicating whether or not to raise events</param>
        public void Delete(IProductVariant productVariant, bool raiseEvents = true)
        {
            if (raiseEvents)
            {
                if (Deleting.IsRaisedEventCancelled(new DeleteEventArgs <IProductVariant>(productVariant), this))
                {
                    ((ProductVariant)productVariant).WasCancelled = true;
                    return;
                }
            }

            using (new WriteLock(Locker))
            {
                var uow = _uowProvider.GetUnitOfWork();
                using (var repository = _repositoryFactory.CreateProductVariantRepository(uow))
                {
                    repository.Delete(productVariant);
                    uow.Commit();
                }
            }
            if (raiseEvents)
            {
                Deleted.RaiseEvent(new DeleteEventArgs <IProductVariant>(productVariant), this);
            }
        }
Beispiel #28
0
        /// <summary>
        /// Permanently deletes an <see cref="IMedia"/> object as well as all of its Children.
        /// </summary>
        /// <remarks>
        /// Please note that this method will completely remove the Media from the database,
        /// as well as associated media files from the file system.
        /// </remarks>
        /// <param name="media">The <see cref="IMedia"/> to delete</param>
        /// <param name="userId">Id of the User deleting the Media</param>
        public void Delete(IMedia media, int userId = 0)
        {
            if (Deleting.IsRaisedEventCancelled(new DeleteEventArgs <IMedia>(media), this))
            {
                return;
            }

            //Delete children before deleting the 'possible parent'
            var children = GetChildren(media.Id);

            foreach (var child in children)
            {
                Delete(child, userId);
            }

            var uow = _uowProvider.GetUnitOfWork();

            using (var repository = _repositoryFactory.CreateMediaRepository(uow))
            {
                repository.Delete(media);
                uow.Commit();
            }

            Deleted.RaiseEvent(new DeleteEventArgs <IMedia>(media, false), this);

            Audit.Add(AuditTypes.Delete, "Delete Media performed by user", userId, media.Id);
        }
        /// <summary>
        /// Deletes a <see cref="IStoreSetting"/>
        /// </summary>
        /// <param name="storeSetting">
        /// The store Setting.
        /// </param>
        /// <param name="raiseEvents">
        /// Optional boolean indicating whether or not to raise events
        /// </param>
        public void Delete(IStoreSetting storeSetting, bool raiseEvents = true)
        {
            if (raiseEvents)
            {
                if (Deleting.IsRaisedEventCancelled(new DeleteEventArgs <IStoreSetting>(storeSetting), this))
                {
                    ((StoreSetting)storeSetting).WasCancelled = true;
                    return;
                }
            }

            using (new WriteLock(Locker))
            {
                var uow = _uowProvider.GetUnitOfWork();
                using (var repository = _repositoryFactory.CreateStoreSettingRepository(uow))
                {
                    repository.Delete(storeSetting);
                    uow.Commit();
                }
            }
            if (raiseEvents)
            {
                Deleted.RaiseEvent(new DeleteEventArgs <IStoreSetting>(storeSetting), this);
            }
        }
Beispiel #30
0
        public async Task Delete(ConfigModel conf, User user, MailWindow inbox)
        {
            using (ImapClient client = new ImapClient())
            {
                await client.ConnectAsync(conf.ImapServer, conf.ImapPort);

                client.Authenticate(user.Mail, user.Password);
                var Folder = client.GetFolder(ListMessages.fold);
                Folder.Open(MailKit.FolderAccess.ReadWrite);

                if (client.Capabilities.HasFlag(ImapCapabilities.SpecialUse))
                {
                    Deleting content = new Deleting("Are you sure? Your message will be move into trash folder.");
                    content.ShowDialog();
                    bool result = content.result;
                    if (result == true)
                    {
                        var trash = client.GetFolder(SpecialFolder.Trash);
                        Folder.MoveTo(Message.SelectedMails, trash);
                        new ListMessages().Refresh(user, conf, inbox);
                    }
                }
                else
                {
                    Deleting content = new Deleting("Are you sure your IMAP Server do not support trash folder. Message wil be deleted ");
                    bool     result  = content.result;
                    if (result == true)
                    {
                        Folder.AddFlags(Message.SelectedMails, MailKit.MessageFlags.Deleted, false);
                        new ListMessages().Refresh(user, conf, inbox);
                    }
                }
            }
        }