/// <summary>
 /// This will be called by RabbitMQ
 /// </summary>
 /// <param name="event"></param>
 /// <returns></returns>
 public Task Handle(TransferCreatedEvent @event)
 {
     _transferRepository.Add(new Models.TransferLog {
         FromAccount = @event.From, ToAccount = @event.To, TransferAmount = @event.Amount
     });
     return(Task.CompletedTask);
 }
        public void TestCRUD()
        {
            Core.Entities.Transfer read;
            var entity = testEntity;

            repository.Add(entity);
            Assert.IsTrue(entity.TransferId > 0, "TransferId not set");

            read = repository.Read(entity.TransferId);
            Assert.IsNotNull(read);
            Assert.IsNotNull(read.FromBankAccount);
            Assert.IsNotNull(read.FromBankAccount.Name);
            Assert.IsNotNull(read.FromBankAccount.Bank);
            Assert.IsNotNull(read.FromBankAccount.Bank.Name);
            Assert.IsNotNull(read.ToBankAccount);
            Assert.IsNotNull(read.ToBankAccount.Name);
            Assert.IsNotNull(read.ToBankAccount.Bank);
            Assert.IsNotNull(read.ToBankAccount.Bank.Name);
            Assert.IsNotNull(read.Category);
            Assert.IsNotNull(read.Category.Name);

            CompareTransfers(entity, read, "Read");

            entity.Name += "-UPDATE";
            repository.Update(entity);
            read = repository.Read(entity.TransferId);
            Assert.IsNotNull(read);
            CompareTransfers(entity, read, "Update");

            repository.Delete(entity);

            read = repository.Read(entity.TransferId);
            Assert.IsNull(read);
        }
Ejemplo n.º 3
0
        public string Post([FromBody] TransferModel model)
        {
            if (!ModelState.IsValid)
            {
                return("Поля перевода указаны неверно");
            }

            ApplicationUser fromUser = _userManager.Find(User.Identity.Name);
            ApplicationUser toUser   = _userManager.Find(model.ToUserName);

            if (fromUser.Email == toUser.Email)
            {
                return("Имена отправителя и получателя совпадают!");
            }

            var powwwers = model.Powwwers;

            if (fromUser.Powwwers < powwwers)
            {
                return("Недостаточно средств для перевода!");
            }
            else
            {
                _userManager.ChangeBalance(fromUser, -powwwers);
                _userManager.ChangeBalance(toUser, powwwers);

                _transferRepo.Add(fromUser, toUser, powwwers);
            }

            var successMessage = $"{fromUser.Email} перевел {toUser.Email} {powwwers} powwwer(s)!. Баланс: {fromUser.Powwwers}";

            return(successMessage);
        }
Ejemplo n.º 4
0
 private void PersistPayment(TransferRequest request, Transfer response)
 {
     _iConnectionFactory.RunTx((con, tx) =>
     {
         _iTransferRepository.Add(con, tx, response);
         _iTransferRequestRepository.Delete(con, tx, request);
     });
 }
Ejemplo n.º 5
0
        public Guid Add(Transfer transfer)
        {
            var cartId = _userRepository.GetCartId(transfer.UserId);

            transfer.CartId = cartId;
            transfer.Status = Status.Pending;
            transfer        = _transferRepository.Add(transfer);
            return(transfer.Id);
        }
 public Task Handle(TranferCreatedEvent @event)
 {
     return(transferRepository.Add(new Models.TransferLog
     {
         Amount = @event.Amount,
         FromAccount = @event.From,
         ToAccount = @event.To
     }));
 }
Ejemplo n.º 7
0
 public Task Handler(TransferCreatedEvent @event)
 {
     _transferRepository.Add(new TransferLog()
     {
         FromAccount    = @event.From.ToString(),
         ToAccount      = @event.To.ToString(),
         TransferAmount = @event.Amount
     });
     return(Task.CompletedTask);
 }
Ejemplo n.º 8
0
 public Task Handle(TransferCreatedEvent @event)
 {
     _transferRepository.Add(new TransferLog()
     {
         FromAccount = @event.From,
         ToAccount   = @event.To,
         Amounth     = @event.Amounth
     });
     return(Task.CompletedTask);
 }
 public Task Handle(TransferCreatedEvent @event)
 {
     _transferRepository.Add(new TransferLog()
     {
         AccountFrom    = @event.From,
         AccountTo      = @event.To,
         TransferAmount = @event.Amount
     });
     return(Task.CompletedTask);
 }
Ejemplo n.º 10
0
 public Task Handle(TransferCreatedEvent @event)
 {
     _transferRepository.Add(new TransferLog()
     {
         SourceAccount  = @event.Source,
         TargetAccount  = @event.Target,
         TransferAmount = @event.Amount
     });
     return(Task.CompletedTask);
 }
Ejemplo n.º 11
0
 public Task Handle(TransferCreatedEvent @event)
 {
     _transferRepository.Add(new TransferLog
     {
         FromAccount    = @event.From,
         ToAccount      = @event.To,
         TransferAmount = @event.Amount
     });
     Console.WriteLine("saved transfer log");
     return(Task.CompletedTask);
 }
Ejemplo n.º 12
0
 public Task Handle(TransferCreatedEvent @event)
 {
     _repo.Add(new TransferLog()
     {
         FromAccount    = @event.From,
         ToAccount      = @event.To,
         TransferAmount = @event.Amount,
         TransferTime   = DateTime.Now
     });
     return(Task.CompletedTask);
 }
Ejemplo n.º 13
0
 public Task Handle(TransferCreatedEvent @event)
 {
     _transferRepository.Add(new TransferLog()
     {
         Timestamp      = DateTimeOffset.Now,
         FromAccount    = @event.From,
         ToAccount      = @event.To,
         TransferAmount = @event.Amount
     });
     return(Task.CompletedTask);
 }
 public Task Handle(TransferCreatedEvent @event)
 {
     // Save this event data to database if required.
     _transferRepository.Add(new TransferLog()
     {
         FromAccount    = @event.From,
         ToAccount      = @event.To,
         TransferAmount = @event.Amount
     });
     return(Task.CompletedTask);
 }
Ejemplo n.º 15
0
        public Task Handle(TransferCreatedEvent @event)
        {
            _transferRepository.Add(new TransferLog
            {
                FromAccount    = @event.From,
                ToAccount      = @event.To,
                TransferAmount = @event.Amount,
                CreateDate     = DateTime.Now
            });

            return(Task.CompletedTask);
        }
        public Task Handle(TransferCreatedEvent @event)
        {
            var log = new TransferLog
            {
                FromAccount    = @event.From,
                ToAccount      = @event.To,
                TransferAmount = @event.Amount
            };

            _transferRepository.Add(log);
            return(Task.CompletedTask);
        }
Ejemplo n.º 17
0
        public Task Handle(TransferCreatedEvent @event)
        {
            // Here we can do whatever we want...
            // Make calculation, talk to another API or service, etc...
            _transferRepository.Add(new TransferLog()
            {
                AccountFrom = @event.FromAccount,
                ToAccount   = @event.ToAccount,
                Amount      = @event.Amount
            });

            return(Task.CompletedTask);
        }
Ejemplo n.º 18
0
        public int AddTransfer(Transfer transfer, ref Error error)
        {
            _validateTransfer(transfer, ref error);

            if (error.ErrorCode != ErrorCode.OKAY)
            {
                return(-1);
            }

            transfer.Amount = Math.Abs(transfer.Amount); //If a negative nuber is provided, make it positive
            var transferId = _transferRepository.Add(transfer.MapToEntity());

            return(transferId);
        }
Ejemplo n.º 19
0
 public void Add(TransferLog transfer)
 {
     _transfer.Add(transfer);
 }
Ejemplo n.º 20
0
 public void Add(TransferLog transferLog)
 {
     _transferRepository.Add(transferLog);
 }
 public Task Handle(TransferCreatedEvent @event)
 {
     _transferRepository.Add(new TransferLog(fromAccount: @event.From, toAccount: @event.To, transferAmount: @event.Amount));
     return(Task.CompletedTask);
 }