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 }); }
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() }); }
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 });
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 }); }
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, }); }
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, }); }