Ejemplo n.º 1
0
        public ActionResult Create(TransferViewModel transferVm)
        {
            if (ModelState.IsValid)
            {
                _transferRepository.Create(transferVm.Transfer);

                _bankAccountLogic.CalculateBalanceOfAllAccounts();
                return(RedirectToAction("Index"));
            }

            return(View(transferVm));
        }
        public async Task <IActionResult> Create(TransferJsonModel transferJson)
        {
            if (transferJson == null)
            {
                return(BadRequest());
            }

            var transfer = _mapper.Map <TransferJsonModel, Transfer>(transferJson);

            transfer.Date = DateTime.Now;
            await _transferRepository.Create(transfer);

            await _transferRepository.CreateComunication(
                await _transferRepository.GetItemByDate(transfer.Date),
                transferJson.CashAccountFrom_Id,
                transferJson.CashAccountTo_Id);

            return(Ok());
        }
Ejemplo n.º 3
0
 public IActionResult PostTransfer([FromBody] SaveTransferResource record)
 {
     if (ModelState.IsValid)
     {
         try {
             repo.Create(mapper.Map <SaveTransferResource, Transfer>(record));
             SendNotificationsToClients();
             return(StatusCode(200, new {
                 response = ApiMessages.RecordCreated()
             }));
         } catch (Exception exception) {
             LoggerExtensions.LogException(0, logger, ControllerContext, record, exception);
             return(StatusCode(490, new {
                 response = ApiMessages.RecordNotSaved()
             }));
         }
     }
     LoggerExtensions.LogException(0, logger, ControllerContext, record, null);
     return(StatusCode(400, new {
         response = ApiMessages.InvalidModel()
     }));
 }
Ejemplo n.º 4
0
 public async Task Handle(TransferCompletedEvent @event)
 {
     await _transferRepository.Create(@event.From, @event.To, @event.Amount);
 }