Ejemplo n.º 1
0
        public ActionResult GetStatsSearch(StatsVM stats)
        {
            var srVM = _service.GetUserStats(stats);

            return PartialView("GetStatsSearch", srVM);
        }
Ejemplo n.º 2
0
        public StatsResultVM GetUserStats(StatsVM stats)
        {
            var dateLow = Convert.ToDateTime(stats.DateLow);
            var dateHigh = Convert.ToDateTime(stats.DateHigh);
            dateHigh = dateHigh.AddDays(1);

            var rooms = _repo.GetAllChatRoomsByDate(dateLow, dateHigh);
            var users = _repo.GetActiveAdminChatUsers();

            string[] split = stats.UsersString.Split(',');
            int[] uId = new int[split.Length];
            List<ChatUser> usersList = new List<ChatUser>();

            if (!split.Contains("all"))
            {
                for (int i = 0; i < split.Length; i++)
                {
                    int num;
                    num = Convert.ToInt32(split[i]);
                    uId[i] = num;
                }
                foreach (var u in users)
                {
                    if (uId.Contains(u.ChatUserId))
                    {
                        usersList.Add(u);
                    }
                }
            }
            else
            {
                foreach (var u in users)
                {
                        usersList.Add(u);
                }
            }

            StatsResultVM srVM = new StatsResultVM();
            srVM.DateLow = stats.DateLow;
            srVM.DateHigh = stats.DateHigh;
            srVM.UsersString = stats.UsersString;

            foreach (var uil in usersList)
            {
                StatItem statItem = new StatItem();
                statItem.UserName = uil.FirstName + " " + uil.LastName;
                statItem.RoomCount = rooms.Where(r => r.AdminChatUserId == uil.ChatUserId).Count();
                statItem.UserId = uil.ChatUserId;
                srVM.StatItems.Add(statItem);
                srVM.TotalCount += statItem.RoomCount;
            }

             var userOrderByRoomCount = srVM.StatItems.OrderByDescending(i => i.RoomCount).ToList();
             srVM.StatItems = userOrderByRoomCount;

            return srVM;
        }
Ejemplo n.º 3
0
        // Methods used by Stats module
        public ActionResult GetStats()
        {
            ViewBag.MenuBar = "Stats";
            var currentUser = _service.GetChatUserByUsername(HttpContext.User.Identity.Name.ToString());
            ViewBag.UserNameFullName = currentUser.FirstName + " " + currentUser.LastName;
            ViewBag.IsAdmin = currentUser.IsAdmin;

            var activeUsers = _repo.GetActiveAdminChatUsers();

            StatsVM stats = new StatsVM();

            stats.Users = activeUsers;
            stats.DateLow = GetLocalTime().ToShortDateString();

            stats.DateHigh = GetLocalTime().ToShortDateString();

            return View(stats);
        }