Example #1
0
 public static MusicShort FromMusic(Music m)
 {
     return(new MusicShort()
     {
         id = m.Id,
         uploader = AppUserShort.FromAppUser(m.Uploader),
         title = m.Title,
         titleunicode = m.TitleUnicode,
         artist = m.Artist,
         artistunicode = m.ArtistUnicode,
         locked = m.Locked,
         date = m.Date
     });
 }
Example #2
0
 public static CommentDetail FromComment(Comment c, bool admin = false)
 {
     return(new CommentDetail()
     {
         id = c.Id,
         mapid = c.MapId,
         user = AppUserShort.FromAppUser(c.User),
         parentcommentid = c.ParentCommentId,
         datetime = c.DateTime,
         content = c.Locked && !admin ? "" : c.Content,
         locked = c.Locked,
         like = c.LikeDislikes.AsQueryable().Where(l => !l.IsDislike).Count(),
         dislike = c.LikeDislikes.AsQueryable().Where(l => l.IsDislike).Count()
     });
 }
Example #3
0
 public static ReportDetail FromReport(Report r)
 {
     return(new ReportDetail()
     {
         id = r.Id,
         date = r.Date,
         from = r.From,
         type = r.Type,
         target = r.Target,
         reason = r.Reason,
         handled = r.Handled,
         handledby = (r.HandledBy is null) ? null : AppUserShort.FromAppUser(r.HandledBy),
         additional = r.Additional,
         lastmodified = r.LastModified
     });
Example #4
0
 public static MusicDetailed FromMusic(Music m)
 {
     return(new MusicDetailed()
     {
         id = m.Id,
         uploader = AppUserShort.FromAppUser(m.Uploader),
         title = m.Title,
         titleunicode = m.TitleUnicode,
         artist = m.Artist,
         artistunicode = m.ArtistUnicode,
         description = m.Description,
         locked = m.Locked,
         mapscount = m.Maps.AsQueryable().Count(),
         date = m.Date
     });
 }
Example #5
0
 public static MapShort FormMap(Map m)
 {
     return(new MapShort()
     {
         id = m.Id,
         mapname = m.MapName,
         difficulty = m.Difficulty,
         proved = m.Proved,
         rate = m.Rates.AsQueryable().DefaultIfEmpty(new Rate()).Average(r => r.RateScore),
         plays = m.PlayRecords.AsQueryable().Count(),
         favorites = m.Favorites.AsQueryable().Count(),
         music = MusicShort.FromMusic(m.Music),
         uploader = AppUserShort.FromAppUser(m.Uploader),
         locked = m.Locked,
     });
 }
Example #6
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,
     });
 }