//Remove a payeer or payer from the database based on the id
 public bool RemovePayerPayee(int id)
 {
     using (var context = new FinanceEDMContainer())
     {
         var record = context.PayerPayees.Where(e => e.PPId == id).Single();
         context.PayerPayees.Remove(record);
         context.SaveChanges();
     }
     return(true);
 }
 //remove a transaction by id
 public bool RemoveTransaction(int id)
 {
     using (var context = new FinanceEDMContainer())
     {
         var remove = context.Transactions.Where(e => e.TransactionId == id).Single();
         context.Transactions.Remove(remove);
         context.SaveChanges();
     }
     return(true);
 }
 //add a payer or payee to the database
 public bool AddPayerPayee(PayerPayee obj)
 {
     using (var context = new FinanceEDMContainer())
     {
         //obj.UserDetailsUserId = Session.SessionID;
         obj.UserDetailsUserId = 1;
         context.PayerPayees.Add(obj);
         context.SaveChanges();
     }
     return(true);
 }
 //Add a transaction to the database
 public bool AddTransaction(List <Transaction> obj)
 {
     using (var context = new FinanceEDMContainer())
     {
         foreach (Transaction item in obj)
         {
             context.Transactions.Add(item);
             context.SaveChanges();
         }
     }
     return(true);
 }
 //update a payer or payee based on the id
 public bool UpdatePayerPayee(PayerPayee obj)
 {
     using (var context = new FinanceEDMContainer())
     {
         var record = context.PayerPayees.SingleOrDefault(e => e.PPId == obj.PPId);
         record.Name    = obj.Name;
         record.Address = obj.Address;
         record.DOB     = obj.DOB;
         record.Email   = obj.Email;
         //obj.UserDetailsUserId = Session.SessionID;
         record.UserDetailsUserId = 1;
         context.SaveChanges();
     }
     return(true);
 }
 //update the transaction fields
 public bool UpdateTransaction(Transaction obj)
 {
     using (var context = new FinanceEDMContainer())
     {
         var record = context.Transactions.SingleOrDefault(e => e.TransactionId == obj.TransactionId);
         record.Category        = obj.Category;
         record.Date            = obj.Date;
         record.Description     = obj.Description;
         record.PayerPayeePPId  = obj.PayerPayeePPId;
         record.Recuring        = obj.Recuring;
         record.TransactionId   = obj.TransactionId;
         record.TransactionType = obj.TransactionType;
         context.SaveChanges();
     }
     return(true);
 }
 //register new user
 public bool AddUser(UserDetails obj)
 {
     using (var context = new FinanceEDMContainer())
     {
         var userRecord = context.UserDetails.Where(e => e.Email == obj.Email);
         if (userRecord.Any())
         {
             return(false);
         }
         else
         {
             context.UserDetails.Add(obj);
             context.SaveChanges();
         }
     }
     return(true);
 }