Exemple #1
0
        public IActionResult Online()
        {
            int UserId = int.Parse(User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.PrimarySid).Value);

            ViewBag.cash = _context.Users.Where(c => c.Id == UserId).First().Cash;
            var modelLog = _context.Logs.Where(c => c.LogStatus == true && (c.StartDate <DateTime.Now && c.StartDate> DateTime.Now.AddHours(-2))).ToLookup(c => c.UserId);
            List <UserTranViewModel> list = new List <UserTranViewModel>();
            List <User> listUser          = new List <User>();

            UserTranViewModel userView = new UserTranViewModel();

            foreach (var lg in modelLog)
            {
                listUser.Add(lg.First().User);
            }
            foreach (User item in listUser)
            {
                var    usertarn = _context.Transactions.Where(c => c.SendUserId == item.Id);
                double amount   = 0;
                foreach (var tr in usertarn)
                {
                    amount += tr.Amount;
                }
                userView = new UserTranViewModel()
                {
                    Users     = item,
                    tranCount = usertarn.Count(),
                    tranDis   = (amount / 100)
                };
                list.Add(userView);
            }

            return(View(list));
        }
Exemple #2
0
        public IActionResult BlockUser()
        {
            int UserId = int.Parse(User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.PrimarySid).Value);

            ViewBag.cash = _context.Users.Where(c => c.Id == UserId).First().Cash;
            var model = _context.Users.Where(c => c.Acvited == false);
            List <UserTranViewModel> list     = new List <UserTranViewModel>();
            UserTranViewModel        userView = new UserTranViewModel();

            foreach (User item in model)
            {
                var    usertarn = _context.Transactions.Where(c => c.SendUserId == item.Id);
                double amount   = 0;
                foreach (var tr in usertarn)
                {
                    amount += tr.Amount;
                }
                userView = new UserTranViewModel()
                {
                    Users     = item,
                    tranCount = usertarn.Count(),
                    tranDis   = (amount / 100)
                };
                list.Add(userView);
            }

            return(View(list));
        }