Example #1
0
 public IActionResult InitializeTransfer([FromBody] AmountForPayeeModel model)
 {
     try
     {
         int      userid = Int32.Parse(User.Claims.Where(x => x.Type == ClaimTypes.Email).FirstOrDefault()?.Value);
         User     user   = _transferService.GetById(userid);
         string   payeename;
         Transfer transfer   = _transferService.CreateTransfer(user, model.PayeeId, model.Amount, out payeename);
         int      newBalance = _transferService.UserBalance(user);
         return(Ok(new
         {
             Id = transfer.Id,
             CorrespondedTo = payeename,
             Amount = transfer.Amount,
             OperatedAt = transfer.OperatedAt,
             Balance = newBalance
         }));
     }
     catch (Exception ex)
     {
         return(BadRequest(new { message = ex.Message }));
     }
 }