Exemplo n.º 1
0
        private TopStatistic GetTopUsersByorder()
        {
            TopStatistic result = new TopStatistic();
            result.Id = 0;
            result.Title = "Top users by order";
            result.Count = 10;
            result.ValueTitle = "Orders";
            
            result.Data = db.UserChoices
                .Where(uc => uc.confirm)
                .GroupBy(uс => uс.UserID)
                .Select(uc => new UserData
                {
                    UserId = uc.Key,
                    UserName = "",
                    Value = uc.Count().ToString()
                })
                .Take(10)
                .OrderByDescending(ud => ud.Value)
                .ToList();

            Dictionary<string, ApplicationUser> users = UserManager.Users.ToDictionary(user => user.Id);
            foreach (var data in result.Data)
            {
                data.UserName = users[data.UserId].UserName;
            }
            
            return result;               
        }
Exemplo n.º 2
0
 public IHttpActionResult GetTop(int id)
 {
     TopStatistic top = new TopStatistic();
     return Ok(top);
 }