示例#1
0
        /// <summary>
        /// Deletes a <see cref="IStoreSetting"/>
        /// </summary>
        /// <param name="storeSetting"></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);
            }
        }
示例#2
0
        /// <summary>
        /// Deletes a single <see cref="IInvoice"/>
        /// </summary>
        /// <param name="invoice">The <see cref="IInvoice"/> to be deleted</param>
        /// <param name="raiseEvents">Optional boolean indicating whether or not to raise events</param>
        public void Delete(IInvoice invoice, bool raiseEvents = true)
        {
            if (raiseEvents)
            {
                if (Deleting.IsRaisedEventCancelled(new DeleteEventArgs <IInvoice>(invoice), this))
                {
                    ((Invoice)invoice).WasCancelled = true;
                    return;
                }
            }

            DeleteAppliedPayments(invoice);

            DeleteOrders(invoice);

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

            if (raiseEvents)
            {
                Deleted.RaiseEvent(new DeleteEventArgs <IInvoice>(invoice), this);
            }
        }
示例#3
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);
        }
示例#4
0
        /// <summary>
        /// Deletes a <see cref="IShipMethod"/>
        /// </summary>
        /// <param name="shipMethod">The <see cref="IShipMethod"/> to delete</param>
        /// <param name="raiseEvents">Optional boolean indicating whether or not to raise events</param>
        public void Delete(IShipMethod shipMethod, bool raiseEvents = true)
        {
            if (raiseEvents)
            {
                if (Deleting.IsRaisedEventCancelled(new DeleteEventArgs <IShipMethod>(shipMethod), this))
                {
                    ((ShipMethod)shipMethod).WasCancelled = true;
                    return;
                }
            }

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

            if (raiseEvents)
            {
                Deleted.RaiseEvent(new DeleteEventArgs <IShipMethod>(shipMethod), this);
            }
        }
示例#5
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);
            }
        }
示例#6
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);
            }
        }
示例#7
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);
            }
        }
示例#8
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);
        }
        /// <summary>
        /// Deletes a single <see cref="IShipCountry"/> object
        /// </summary>
        /// <param name="shipCountry"></param>
        /// <param name="raiseEvents"></param>
        public void Delete(IShipCountry shipCountry, bool raiseEvents = true)
        {
            if (raiseEvents)
            {
                if (Deleting.IsRaisedEventCancelled(new DeleteEventArgs <IShipCountry>(shipCountry), this))
                {
                    ((ShipCountry)shipCountry).WasCancelled = true;
                    return;
                }
            }

            using (new WriteLock(Locker))
            {
                var uow = _uowProvider.GetUnitOfWork();
                using (var repository = _repositoryFactory.CreateShipCountryRepository(uow, _storeSettingService))
                {
                    repository.Delete(shipCountry);
                    uow.Commit();
                }
            }

            if (raiseEvents)
            {
                Deleted.RaiseEvent(new DeleteEventArgs <IShipCountry>(shipCountry), this);
            }
        }
示例#10
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.DefaultKeys.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);
            }
        }
示例#11
0
        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);
                }
            }
        }
示例#12
0
        /// <summary>
        /// Deletes a single <see cref="IProduct"/> object
        /// </summary>
        /// <param name="product">The <see cref="IProduct"/> to delete</param>
        /// <param name="raiseEvents">Optional boolean indicating whether or not to raise events</param>
        public void Delete(IProduct product, bool raiseEvents = true)
        {
            if (raiseEvents)
            {
                if (Deleting.IsRaisedEventCancelled(new DeleteEventArgs <IProduct>(product), this))
                {
                    ((Product)product).WasCancelled = true;
                    return;
                }
            }

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

            if (raiseEvents)
            {
                Deleted.RaiseEvent(new DeleteEventArgs <IProduct>(product), this);
            }
        }
示例#13
0
        /// <summary>
        /// Deletes a single instance of <see cref="IDetachedContentType"/>.
        /// </summary>
        /// <param name="detachedContentType">
        /// The detached content type.
        /// </param>
        /// <param name="raiseEvents">
        /// Optional boolean indicating whether or not to raise events.
        /// </param>
        public void Delete(IDetachedContentType detachedContentType, bool raiseEvents = true)
        {
            if (raiseEvents)
            {
                if (Deleting.IsRaisedEventCancelled(new DeleteEventArgs <IDetachedContentType>(detachedContentType), this))
                {
                    ((DetachedContentType)detachedContentType).WasCancelled = true;
                    return;
                }
            }


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

            if (raiseEvents)
            {
                Deleted.RaiseEvent(new DeleteEventArgs <IDetachedContentType>(detachedContentType), this);
            }
        }
        public Attempt <IUserContent> Delete(IUserContent content)
        {
            if (Deleting.IsRaisedEventCancelled(new DeleteEventArgs <TUserContent>((TUserContent)content), this))
            {
                return(Attempt.Fail <IUserContent>(content, new Exception("blocked by delegated event")));
            }

            _userRepo.Delete(content.Key);

            Deleted.RaiseEvent(new DeleteEventArgs <TUserContent>((TUserContent)content), this);
            _cacheRefresher.Refresh(content.Key);

            return(Attempt.Succeed <IUserContent>(content));
        }
示例#15
0
        /// <summary>
        /// Deletes an <see cref="IDataTypeDefinition"/>
        /// </summary>
        /// <remarks>
        /// Please note that deleting a <see cref="IDataTypeDefinition"/> will remove
        /// all the <see cref="PropertyType"/> data that references this <see cref="IDataTypeDefinition"/>.
        /// </remarks>
        /// <param name="dataTypeDefinition"><see cref="IDataTypeDefinition"/> to delete</param>
        /// <param name="userId">Optional Id of the user issueing the deletion</param>
        public void Delete(IDataTypeDefinition dataTypeDefinition, int userId = 0)
        {
            if (Deleting.IsRaisedEventCancelled(new DeleteEventArgs <IDataTypeDefinition>(dataTypeDefinition), this))
            {
                return;
            }

            var uow = _uowProvider.GetUnitOfWork();

            using (var repository = _repositoryFactory.CreateContentTypeRepository(uow))
            {
                //Find ContentTypes using this IDataTypeDefinition on a PropertyType
                var query = Query <PropertyType> .Builder.Where(x => x.DataTypeDefinitionId == dataTypeDefinition.Id);

                var contentTypes = repository.GetByQuery(query);

                //Loop through the list of results and remove the PropertyTypes that references the DataTypeDefinition that is being deleted
                foreach (var contentType in contentTypes)
                {
                    if (contentType == null)
                    {
                        continue;
                    }

                    foreach (var group in contentType.PropertyGroups)
                    {
                        var types = @group.PropertyTypes.Where(x => x.DataTypeDefinitionId == dataTypeDefinition.Id).ToList();
                        foreach (var propertyType in types)
                        {
                            @group.PropertyTypes.Remove(propertyType);
                        }
                    }

                    repository.AddOrUpdate(contentType);
                }

                var dataTypeRepository = _repositoryFactory.CreateDataTypeDefinitionRepository(uow);
                dataTypeRepository.Delete(dataTypeDefinition);

                uow.Commit();

                Deleted.RaiseEvent(new DeleteEventArgs <IDataTypeDefinition>(dataTypeDefinition, false), this);
            }

            Audit.Add(AuditTypes.Delete, string.Format("Delete DataTypeDefinition performed by user"), userId, dataTypeDefinition.Id);
        }
示例#16
0
        public void Delete(IMemberGroup memberGroup)
        {
            if (Deleting.IsRaisedEventCancelled(new DeleteEventArgs <IMemberGroup>(memberGroup), this))
            {
                return;
            }

            var uow = UowProvider.GetUnitOfWork();

            using (var repository = RepositoryFactory.CreateMemberGroupRepository(uow))
            {
                repository.Delete(memberGroup);
                uow.Commit();
            }

            Deleted.RaiseEvent(new DeleteEventArgs <IMemberGroup>(memberGroup, false), this);
        }
示例#17
0
        /// <summary>
        /// Deletes the <see cref="IAnonymousCustomer"/>
        /// </summary>
        /// <param name="anonymous">
        /// The anonymous customer
        /// </param>
        public void Delete(IAnonymousCustomer anonymous)
        {
            if (Deleting.IsRaisedEventCancelled(new DeleteEventArgs <IAnonymousCustomer>(anonymous), this))
            {
                return;
            }

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

            Deleted.RaiseEvent(new DeleteEventArgs <IAnonymousCustomer>(anonymous), this);
        }
示例#18
0
        /// <summary>
        /// Deletes all media of specified type. All children of deleted media is moved to Recycle Bin.
        /// </summary>
        /// <remarks>This needs extra care and attention as its potentially a dangerous and extensive operation</remarks>
        /// <param name="mediaTypeId">Id of the <see cref="IMediaType"/></param>
        /// <param name="userId">Optional id of the user deleting the media</param>
        public void DeleteMediaOfType(int mediaTypeId, int userId = 0)
        {
            using (new WriteLock(Locker))
            {
                var uow = _uowProvider.GetUnitOfWork();
                using (var repository = _repositoryFactory.CreateMediaRepository(uow))
                {
                    //NOTE What about media that has the contenttype as part of its composition?
                    //The ContentType has to be removed from the composition somehow as it would otherwise break
                    //Dbl.check+test that the ContentType's Id is removed from the ContentType2ContentType table
                    var query = Query <IMedia> .Builder.Where(x => x.ContentTypeId == mediaTypeId);

                    var contents = repository.GetByQuery(query);

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

                    foreach (var content in contents.OrderByDescending(x => x.ParentId))
                    {
                        //Look for children of current content and move that to trash before the current content is deleted
                        var c          = content;
                        var childQuery = Query <IMedia> .Builder.Where(x => x.Path.StartsWith(c.Path));

                        var children = repository.GetByQuery(childQuery);

                        foreach (var child in children)
                        {
                            if (child.ContentType.Id != mediaTypeId)
                            {
                                MoveToRecycleBin(child, userId);
                            }
                        }

                        //Permantly delete the content
                        Delete(content, userId);
                    }
                }

                Audit.Add(AuditTypes.Delete, "Delete Media items by Type performed by user", userId, -1);
            }
        }
示例#19
0
        //private IEnumerable<IMacro> GetAllByAliases(IMacroRepository repo, IEnumerable<string> aliases)
        //{
        //    foreach (var alias in aliases)
        //    {
        //        var q = new Query<IMacro>();
        //        q.Where(macro => macro.Alias == alias);
        //        yield return repo.GetByQuery(q).FirstOrDefault();
        //    }
        //}

        /// <summary>
        /// Deletes an <see cref="IMacro"/>
        /// </summary>
        /// <param name="macro"><see cref="IMacro"/> to delete</param>
        /// <param name="userId">Optional id of the user deleting the macro</param>
        public void Delete(IMacro macro, int userId = 0)
        {
            if (Deleting.IsRaisedEventCancelled(new DeleteEventArgs <IMacro>(macro), this))
            {
                return;
            }

            var uow = UowProvider.GetUnitOfWork();

            using (var repository = RepositoryFactory.CreateMacroRepository(uow))
            {
                repository.Delete(macro);
                uow.Commit();

                Deleted.RaiseEvent(new DeleteEventArgs <IMacro>(macro, false), this);
            }

            Audit(AuditType.Delete, "Delete Macro performed by user", userId, -1);
        }
        /// <summary>
        /// Deletes an <see cref="IDataTypeDefinition"/>
        /// </summary>
        /// <remarks>
        /// Please note that deleting a <see cref="IDataTypeDefinition"/> will remove
        /// all the <see cref="PropertyType"/> data that references this <see cref="IDataTypeDefinition"/>.
        /// </remarks>
        /// <param name="dataTypeDefinition"><see cref="IDataTypeDefinition"/> to delete</param>
        /// <param name="userId">Optional Id of the user issueing the deletion</param>
        public void Delete(IDataTypeDefinition dataTypeDefinition, int userId = 0)
        {
            if (Deleting.IsRaisedEventCancelled(new DeleteEventArgs <IDataTypeDefinition>(dataTypeDefinition), this))
            {
                return;
            }

            var uow = UowProvider.GetUnitOfWork();

            using (var repository = RepositoryFactory.CreateDataTypeDefinitionRepository(uow))
            {
                repository.Delete(dataTypeDefinition);

                uow.Commit();

                Deleted.RaiseEvent(new DeleteEventArgs <IDataTypeDefinition>(dataTypeDefinition, false), this);
            }

            Audit(AuditType.Delete, string.Format("Delete DataTypeDefinition performed by user"), userId, dataTypeDefinition.Id);
        }
        public void Delete(IMemberType memberType, int userId = 0)
        {
            if (Deleting.IsRaisedEventCancelled(new DeleteEventArgs <IMemberType>(memberType), this))
            {
                return;
            }

            using (new WriteLock(Locker))
            {
                _memberService.DeleteMembersOfType(memberType.Id);

                var uow = UowProvider.GetUnitOfWork();
                using (var repository = RepositoryFactory.CreateMemberTypeRepository(uow))
                {
                    repository.Delete(memberType);
                    uow.Commit();

                    Deleted.RaiseEvent(new DeleteEventArgs <IMemberType>(memberType, false), this);
                }
            }
        }
示例#22
0
        /// <summary>
        /// Deletes the entry and all associated rules
        /// </summary>
        /// <param name="entry"></param>
        public Attempt <OperationStatus> Delete(PublicAccessEntry entry)
        {
            var evtMsgs = EventMessagesFactory.Get();

            if (Deleting.IsRaisedEventCancelled(
                    new DeleteEventArgs <PublicAccessEntry>(entry, evtMsgs),
                    this))
            {
                return(Attempt.Fail(OperationStatus.Cancelled(evtMsgs)));
            }

            var uow = UowProvider.GetUnitOfWork();

            using (var repo = RepositoryFactory.CreatePublicAccessRepository(uow))
            {
                repo.Delete(entry);
                uow.Commit();
            }

            Deleted.RaiseEvent(new DeleteEventArgs <PublicAccessEntry>(entry, false, evtMsgs), this);
            return(Attempt.Succeed(OperationStatus.Success(evtMsgs)));
        }
示例#23
0
        /// <summary>
        /// Deletes a <see cref="IAuditLog"/>
        /// </summary>
        /// <param name="auditLog">
        /// The <see cref="IAuditLog"/> to be deleted
        /// </param>
        /// <param name="raiseEvents">
        /// Optional boolean indicating whether or not to raise events
        /// </param>
        public void Delete(IAuditLog auditLog, bool raiseEvents = true)
        {
            if (raiseEvents)
            {
                if (Deleting.IsRaisedEventCancelled(new DeleteEventArgs <IAuditLog>(auditLog), this))
                {
                    ((AuditLog)auditLog).WasCancelled = true;
                    return;
                }
            }

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

            Deleted.RaiseEvent(new DeleteEventArgs <IAuditLog>(auditLog), this);
        }
示例#24
0
        /// <summary>
        /// Deletes a <see cref="INote"/>
        /// </summary>
        /// <param name="note">
        /// The <see cref="INote"/> to be deleted
        /// </param>
        /// <param name="raiseEvents">
        /// Optional boolean indicating whether or not to raise events
        /// </param>
        public void Delete(INote note, bool raiseEvents = true)
        {
            if (raiseEvents)
            {
                if (Deleting.IsRaisedEventCancelled(new DeleteEventArgs <INote>(note), this))
                {
                    ((Note)note).WasCancelled = true;
                    return;
                }
            }

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

            Deleted.RaiseEvent(new DeleteEventArgs <INote>(note), this);
        }
示例#25
0
        public Attempt <OperationStatus> Delete(IDomain domain)
        {
            var evtMsgs = EventMessagesFactory.Get();

            if (Deleting.IsRaisedEventCancelled(
                    new DeleteEventArgs <IDomain>(domain, evtMsgs),
                    this))
            {
                return(Attempt.Fail(OperationStatus.Cancelled(evtMsgs)));
            }

            var uow = UowProvider.GetUnitOfWork();

            using (var repository = RepositoryFactory.CreateDomainRepository(uow))
            {
                repository.Delete(domain);
                uow.Commit();
            }

            var args = new DeleteEventArgs <IDomain>(domain, false, evtMsgs);

            Deleted.RaiseEvent(args, this);
            return(Attempt.Succeed(OperationStatus.Success(evtMsgs)));
        }