public void UpdateBankAccount(BankAccountInfo bankAccount)
 {
     try
     {
         CashFlowManagerEntities db = new CashFlowManagerEntities();
         BankAccount ba = (from b in db.BankAccounts where b.Id == bankAccount.Id select b).SingleOrDefault();
         if (ba != null)
         {
             ba.AccountName = bankAccount.AccountName;
             ba.AccountNumber = bankAccount.AccountNumber;
             ba.Balance = bankAccount.Balance;
             ba.ClientId = bankAccount.ClientId;
         }
         db.Entry(ba).State = EntityState.Modified;
         db.SaveChanges();
     }
     catch (Exception ex)
     {
         Debug.WriteLine(ex.Message);
         throw;
     }
 }
        public void UpdateTransaction(TransactionInfo transaction)
        {
            try
            {
                CashFlowManagerEntities db = new CashFlowManagerEntities();

                var tran = (from t in db.Transactions where t.Id == transaction.Id select t).SingleOrDefault();

                if (tran != null)
                {
                    tran.Narration = transaction.Narration;
                    tran.ScheduleId = transaction.ScheduleId;
                    tran.Amount = transaction.Amount;
                    tran.StartDate = transaction.StartDate;
                    tran.TransactionTypeId = transaction.TransactionTypeId;

                    db.Entry(tran).State = EntityState.Modified;
                    db.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
                throw;
            }
        }
        public void AssociateAndUpdateUser(int userId, Guid? practiceId, string email)
        {
            try
            {
                CashFlowManagerEntities db = new CashFlowManagerEntities();

                if (practiceId != Guid.Empty)
                {
                    var user = (from u in db.UserProfiles where u.UserId == userId select u).SingleOrDefault();

                    if (user != null)
                    {
                        user.PracticeId = practiceId;
                        user.Email = email;
                        db.Entry(user).State = EntityState.Modified;
                        db.SaveChanges();
                    }
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
                throw;
            }
        }