Beispiel #1
0
        public IHttpActionResult AddTransaction(TransactionModel transactionModel)
        {
            try
            {
                Log.Information("File Name: " + _stackFrame.GetMethod().DeclaringType.Name + ".cs " + "NameSpace: " + _stackFrame.GetMethod().DeclaringType.Namespace + " Method Name: AddTransaction()");
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }
                var transactions = _transaction.AddTransaction(transactionModel);

                //if (transactions.TransactionID > 0)
                //{
                Log.Information("File Name: " + _stackFrame.GetMethod().DeclaringType.Name + ".cs " + "AddTransaction() Method Executed Successfully");
                return(Ok(transactions));
                //}
                //else
                //{
                //    Log.Information("File Name: " + _stackFrame.GetMethod().DeclaringType.Name + ".cs " + "AddTransaction() Method Executed Successfully");
                //    return Ok("Invalid Transaction");
                //}
            }
            catch (Exception ex)
            {
                Log.Fatal("Error Message: " + ex.Message + System.Environment.NewLine + System.Environment.NewLine + "Stack Trace Below:" + System.Environment.NewLine + ex.StackTrace + System.Environment.NewLine);
                return(InternalServerError());
            }
            finally
            {
                Log.CloseAndFlush();
            }
        }
Beispiel #2
0
 public void Deposit(int id, decimal amount)
 {
     try
     {
         var account = GetAccountById(id);
         if (account != null)
         {
             account.Balance += amount;
             _Itransaction.AddTransaction(account, amount, "Deposit");
             _dbContext.SaveChanges();
         }
         else
         {
             Console.WriteLine("Account Number does not exists!");
         }
     }
     catch (DbUpdateConcurrencyException e)
     {
         Console.WriteLine(e);
         throw;
     }
 }
 public bool AddTransaction(Guid id, Transaction transaction)
 {
     return(_transaction.AddTransaction(id, transaction));
 }