Ejemplo n.º 1
0
        public decimal GetDepositsAtCounterpartyAndDeliveryPoint(IUnitOfWork UoW, Counterparty counterparty, DeliveryPoint deliveryPoint, DepositType?depositType, DateTime?before = null)
        {
            DepositOperation    operationAlias = null;
            DepositsQueryResult result         = null;
            var queryResult = UoW.Session.QueryOver(() => operationAlias)
                              .Where(() => operationAlias.Counterparty == counterparty)
                              .Where(() => operationAlias.DeliveryPoint == deliveryPoint)
            ;

            if (before.HasValue)
            {
                queryResult.Where(() => operationAlias.OperationTime < before);
            }
            if (depositType.HasValue)
            {
                queryResult.Where(() => operationAlias.DepositType == depositType);
            }

            var deposits = queryResult.SelectList(list => list
                                                  .SelectSum(() => operationAlias.ReceivedDeposit).WithAlias(() => result.Received)
                                                  .SelectSum(() => operationAlias.RefundDeposit).WithAlias(() => result.Refund)
                                                  ).TransformUsing(Transformers.AliasToBean <DepositsQueryResult>()).List <DepositsQueryResult>()
                           .FirstOrDefault()?
                           .Deposits ?? 0;

            return(deposits);
        }
Ejemplo n.º 2
0
        public async Task Deposit([FromBody] DepositOperation operation)
        {
            await _repository.Increment(operation.AccountNumber, operation.Amount);

            await _repository.Decrement(operation.AccountNumber, operation.Rate);

            await _operationRepository.Register(operation);

            Ok();
        }
Ejemplo n.º 3
0
 public static void TryCatchAmount(DepositOperation depositOperation, decimal amount)
 {
     try
     {
         depositOperation(amount);
     }
     catch (NonPositiveDepositAmountException e)
     {
         AmountExcLog(e);
     }
     catch (MaxDepositAmountException e)
     {
         AmountExcLog(e);
     }
     catch (WithdrawCountException e)
     {
         AmountExcLog(e);
     }
     catch (MinBalanceReachedException e)
     {
         AmountExcLog(e);
     }
 }