Esempio n. 1
0
        public static bool AddCashUser(int userId)
        {
            var success = false;

            try
            {
                var cash = new UserCashAccountModel()
                {
                    UserId = userId,
                    Amount = 0
                };

                using (UserCashAccountContext db = new UserCashAccountContext())
                {
                    db.UserCashAccounts.Add(cash);
                    db.SaveChanges();
                    success = true;
                }
            }
            catch (Exception e)
            {
                success = false;
            }

            return(success);
        }
Esempio n. 2
0
        public static double AvailableMoneyByUserId(int userId)
        {
            double money = 0;

            try
            {
                var cash = new UserCashAccountModel()
                {
                    UserId = userId,
                    Amount = 0
                };

                using (UserCashAccountContext db = new UserCashAccountContext())
                {
                    var userCash = db.UserCashAccounts.FirstOrDefault(p => p.UserId == userId);

                    money = userCash == null ? 0 : userCash.Amount;
                }
            }
            catch (Exception e)
            {
                money = 0;
            }

            return(money);
        }