예제 #1
0
        ////מחזיר רשימת הפקדות לפי ת"ז
        //public static List<DepositDTO> GetDeposits(int userId)
        //{
        //    List<DepositDTO> deposits = new List<DepositDTO>();
        //    db.Deposits.Where(i => i.userId == userId).ToList().ForEach(w => deposits.Add(DepositCast.CastToDTO(w)));
        //    return deposits;
        //}


        public static List <DepositDTO> GetDeposits()
        {
            db = new controlPrintEntities();
            List <DepositDTO> deposits = new List <DepositDTO>();

            db.Deposits.ToList().ForEach(w => deposits.Add(DepositCast.CastToDTO(w)));

            deposits.ForEach(d => { User u2 = db.Users.Where(u => u.userId == d.userId).FirstOrDefault(); d.userName = u2.userName; d.userTz = u2.userTz; });
            return(deposits);
        }
예제 #2
0
 public static double?getBalanceByUser(UserDTO user)
 {
     db = new controlPrintEntities();
     if (user != null)
     {
         double?depositSum   = db.Users.FirstOrDefault(u => u.userId == user.userId).Deposits.ToList().Sum(d => d.depositAmount);
         double?costPrintSum = db.Users.FirstOrDefault(u => u.userId == user.userId).PrintHistories.ToList().Sum(p => p.costPrint);
         return(depositSum - costPrintSum);
     }
     return(0);
 }