public async Task<IHttpActionResult> CreateTransaction(Transaction transaction)
        {
            transaction.Created = DateTimeOffset.Now;
           // transaction.CategoryId = transaction.Category.Id;
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }
            if (transaction.IsDebit)
                transaction.Amount *= -1;
            transaction.CategoryId = transaction.Category.Id;
            transaction.Category = null;
            var account = db.Accounts.Find(transaction.AccountId);
            account.Balance += transaction.Amount;
            if(transaction.IsReconciled)
                account.RecBalance += transaction.Amount;
            account.Transactions.Add(transaction);

            await db.SaveChangesAsync();
            return Ok();
        }
 private static void FindEdited(string desc, decimal? a, int? catId, bool rec, Transaction transaction)
 {
     if (!String.IsNullOrWhiteSpace(desc))
         transaction.Description = desc;
     if (a != null)
     {
         transaction.Account.Balance -= transaction.Amount;
         transaction.Account.RecBalance -= transaction.Amount;
         transaction.Amount = (decimal)a;
         transaction.Account.Balance += (decimal)a;
         transaction.Account.RecBalance += (decimal)a;
     }
     if (catId != null)
         transaction.CategoryId = (int)catId;
     if (transaction.IsReconciled != rec)
     {
         transaction.IsReconciled = rec;
         if (!rec)
             transaction.Account.RecBalance -= (decimal)a;
         else
             transaction.Account.RecBalance += (decimal)a;
     }
 }