示例#1
0
        public void DisburseClaim(DisburseClaim command, IElectionsReadModel electionsReadModel)
        {
            var         elections = electionsReadModel.GetElectionsForParticipant(command.ParticipantId);
            ElectionDto election  = null;

            if (TryGetElection(elections, _state.ClaimType, out election))
            {
                var electionBalance = electionsReadModel.GetElectionBalance(election.Id).BalanceRemaining;
                if (electionBalance - _state.ClaimAmount.Amount < 0)
                {
                    RaiseClaimNotDisbursedEvent(command,
                                                string.Format(
                                                    "Your remaining election balance is {0} which is not enough to cover your claim for {1}",
                                                    electionBalance, _state.ClaimAmount.Amount));
                    return;
                }
                RaiseClaimDisbursedEvent(command, election.Id);
            }
            else
            {
                RaiseClaimNotDisbursedEvent(command, string.Format("No election matches the claim type '{0}'", _state.ClaimType));
            }
        }
 public DisburseClaimCommandHandler(IRepository <ClaimRequest> repository, IElectionsReadModel electionsReadModel)
     : base(claim => new Guid(claim.ClaimId))
 {
     _repository         = repository;
     _electionsReadModel = electionsReadModel;
 }
 public void DisburseClaim(DisburseClaim command, IElectionsReadModel electionsReadModel)
 {
     var elections = electionsReadModel.GetElectionsForParticipant(command.ParticipantId);
     ElectionDto election = null;
     
     if (TryGetElection(elections, _state.ClaimType, out election))
     {
         var electionBalance = electionsReadModel.GetElectionBalance(election.Id).BalanceRemaining;
         if (electionBalance - _state.ClaimAmount.Amount < 0)
         {
             RaiseClaimNotDisbursedEvent(command,
                                         string.Format(
                                             "Your remaining election balance is {0} which is not enough to cover your claim for {1}",
                                             electionBalance, _state.ClaimAmount.Amount));
             return;
         }
         RaiseClaimDisbursedEvent(command, election.Id);
     }
     else
     {
         RaiseClaimNotDisbursedEvent(command, string.Format("No election matches the claim type '{0}'", _state.ClaimType));
     }
 }
 public ElectionsController(IElectionsReadModel electionsReadModel, ICompaniesReadModel companiesReadModel, ISendCommandsAndWaitForAResponse commandSender)
 {
     _electionsReadModel = electionsReadModel;
     _companiesReadModel = companiesReadModel;
     _commandSender = commandSender;
 }
示例#5
0
 public ElectionsController(IElectionsReadModel electionsReadModel, ICompaniesReadModel companiesReadModel, ISendCommandsAndWaitForAResponse commandSender)
 {
     _electionsReadModel = electionsReadModel;
     _companiesReadModel = companiesReadModel;
     _commandSender      = commandSender;
 }