Ejemplo n.º 1
0
 public static MapDetailed FormMap(Map m)
 {
     return(new MapDetailed()
     {
         id = m.Id,
         mapname = m.MapName,
         difficulty = m.Difficulty,
         proved = m.Proved,
         description = m.Description,
         rate = RateDetail.FromRates(m.Rates),
         plays = m.PlayRecords.AsQueryable().Count(),
         favorites = m.Favorites.AsQueryable().Count(),
         date = m.Date,
         lastmodified = m.LastModified,
         music = MusicDetailed.FromMusic(m.Music),
         uploader = AppUserShort.FromAppUser(m.Uploader),
         locked = m.Locked,
     });
 }
Ejemplo n.º 2
0
        public static RateDetail FromRates(IEnumerable <Rate> rates)
        {
            var groups = rates.GroupBy(r => r.RateScore);
            var d      = new RateDetail();

            foreach (var g in groups)
            {
                switch (g.Key)
                {
                case 1: d.r1 = g.Count(); break;

                case 2: d.r2 = g.Count(); break;

                case 3: d.r3 = g.Count(); break;

                case 4: d.r4 = g.Count(); break;

                case 5: d.r5 = g.Count(); break;
                }
            }
            return(d);
        }