コード例 #1
0
        /// <summary>
        /// 删除域
        /// </summary>
        public static ResultKey DeleteDomain(Domain entry)
        {
            if (entry == null)
            {
                return(ResultKey.Failure);
            }

            return(repository.Delete(entry));
        }
コード例 #2
0
 /// <summary>
 /// Deletes a domain.
 /// </summary>
 /// <param name="tenantId">Identifies website whose domain is to deleted.</param>
 /// <param name="domainId">Identifies the domain to delete.</param>
 /// <param name="unitOfWork">Unit of work.</param>
 public void Delete(long tenantId, long domainId, IUnitOfWork unitOfWork = null)
 {
     try
     {
         _domainRepository.Delete(tenantId, domainId, unitOfWork);
     }
     catch (ValidationErrorException)
     {
         throw;
     }
     catch (Exception ex)
     {
         throw new ValidationErrorException(new ValidationError(null, ApplicationResource.UnexpectedErrorMessage), ex);
     }
 }
コード例 #3
0
        public bool Invoke(Guid domainId)
        {
            if (domainId == Guid.Empty)
            {
                return(false);
            }

            var domainToDelete = domainRepository.GetById(domainId);

            if (domainToDelete == null)
            {
                return(false);
            }

            domainRepository.Delete(domainToDelete);
            _unitOfWork.Save();

            return(true);
        }
コード例 #4
0
        public async Task <Unit> Handle(DeleteDocumentCommand request, CancellationToken cancellationToken)
        {
            if (request == null)
            {
                throw new ArgumentNullException(nameof(request));
            }

            var document = await domainRepository.GetDocumentByLocation(request.FileLocation);

            if (document == null)
            {
                throw new ValidationException($"Document with Location: {request.FileLocation} doesn't exist.");
            }

            await fileRepository.DeleteFile(document.Name, cancellationToken);

            await domainRepository.Delete(document, cancellationToken);

            return(Unit.Value);
        }
コード例 #5
0
        public Attempt <OperationResult> Delete(IDomain domain)
        {
            EventMessages eventMessages = EventMessagesFactory.Get();

            using (IScope scope = ScopeProvider.CreateScope())
            {
                var deletingNotification = new DomainDeletingNotification(domain, eventMessages);
                if (scope.Notifications.PublishCancelable(deletingNotification))
                {
                    scope.Complete();
                    return(OperationResult.Attempt.Cancel(eventMessages));
                }

                _domainRepository.Delete(domain);
                scope.Complete();

                scope.Notifications.Publish(new DomainDeletedNotification(domain, eventMessages).WithStateFrom(deletingNotification));
            }

            return(OperationResult.Attempt.Succeed(eventMessages));
        }
コード例 #6
0
        public Attempt <OperationResult> Delete(IDomain domain)
        {
            var evtMsgs = EventMessagesFactory.Get();

            using (var scope = ScopeProvider.CreateScope())
            {
                var deleteEventArgs = new DeleteEventArgs <IDomain>(domain, evtMsgs);
                if (scope.Events.DispatchCancelable(Deleting, this, deleteEventArgs))
                {
                    scope.Complete();
                    return(OperationResult.Attempt.Cancel(evtMsgs));
                }

                _domainRepository.Delete(domain);
                scope.Complete();

                deleteEventArgs.CanCancel = false;
                scope.Events.Dispatch(Deleted, this, deleteEventArgs);
            }

            return(OperationResult.Attempt.Succeed(evtMsgs));
        }
コード例 #7
0
 public void DeleteDomain(int id)
 {
     _domainRepository.Delete(id);
 }
コード例 #8
0
 public override void Handle(DeleteAggregateRoot <TRoot> command)
 {
     _repo.Delete(command.Id);
 }