Esempio n. 1
0
 public Deposit GetSelectedDeposit(Deposit deposit)
 {
     using (var context = new TipManagerDBEntities())
     {
         return(deposit = context.Deposits.Where(x => x.DepositID == deposit.DepositID).FirstOrDefault());
     }
 }
Esempio n. 2
0
 public Withdraw GetSelectedWithdraw(Withdraw withdraw)
 {
     using (var context = new TipManagerDBEntities())
     {
         return(withdraw = context.Withdraws.Where(x => x.WithdrawID == withdraw.WithdrawID).FirstOrDefault());
     }
 }
Esempio n. 3
0
 public List <Withdraw> GetDataSourceForWithdraw()
 {
     using (var context = new TipManagerDBEntities())
     {
         return(context.Withdraws.ToList <Withdraw>());
     }
 }
Esempio n. 4
0
 public List <Deposit> GetDataSourceForAddTip()
 {
     using (var context = new TipManagerDBEntities())
     {
         return(context.Deposits.ToList <Deposit>());
     }
 }
Esempio n. 5
0
 public double GetTotal()
 {
     using (var context = new TipManagerDBEntities())
     {
         try
         {
             return(GetTotalMade() - GetTotalSpent());
         }
         catch
         {
             return(0);
         }
     }
 }
Esempio n. 6
0
 public double GetTotalHoursWorked()
 {
     using (var context = new TipManagerDBEntities())
     {
         try
         {
             double sum = context.Deposits.Sum(d => d.HoursWorked);
             return(sum);
         }
         catch
         {
             return(0);
         }
     }
 }
Esempio n. 7
0
 public double GetTotalSpent()
 {
     using (var context = new TipManagerDBEntities())
     {
         try
         {
             double sum = (double)context.Withdraws.Sum(d => d.WithdrawAmount);
             return(sum);
         }
         catch
         {
             return(0);
         }
     }
 }
Esempio n. 8
0
 public double GetTotalMade()
 {
     using (var context = new TipManagerDBEntities())
     {
         try
         {
             double sum = (double)context.Deposits.Sum(d => d.DepositAmount);
             return(sum);
         }
         catch
         {
             return(0);
         }
     }
 }
Esempio n. 9
0
        // This will need to be refactored
        public void AddNewWithdraw(Withdraw withdraw)
        {
            using (var context = new TipManagerDBEntities())
            {
                if (withdraw.WithdrawID == 0)
                {
                    context.Withdraws.Add(withdraw);
                }
                else
                {
                    context.Entry(withdraw).State = EntityState.Modified;
                }

                context.SaveChanges();
            }
        }
Esempio n. 10
0
        // This will need to be refactored
        public void AddNewDeposit(Deposit deposit)
        {
            using (var context = new TipManagerDBEntities())
            {
                if (deposit.DepositID == 0)
                {
                    context.Deposits.Add(deposit);
                }
                else
                {
                    context.Entry(deposit).State = EntityState.Modified;
                }

                context.SaveChanges();
            }
        }
Esempio n. 11
0
 public void DeleteWithdraw(Withdraw withdraw)
 {
     using (var context = new TipManagerDBEntities())
     {
         try
         {
             var entry = context.Entry(withdraw);
             if (entry.State == EntityState.Detached)
             {
                 context.Withdraws.Attach(withdraw);
             }
             context.Withdraws.Remove(withdraw);
             context.SaveChanges();
         }
         catch
         {
         }
     }
 }
Esempio n. 12
0
 public void DeleteDeposit(Deposit deposit)
 {
     using (var context = new TipManagerDBEntities())
     {
         try
         {
             var entry = context.Entry(deposit);
             if (entry.State == EntityState.Detached)
             {
                 context.Deposits.Attach(deposit);
             }
             context.Deposits.Remove(deposit);
             context.SaveChanges();
         }
         catch
         {
         }
     }
 }