public async Task <object> MyMusics( [FromQuery][Range(1, 10000)] int?page) { var user = await userManager.GetUserAsync(User); return(user.UploadedMusics.AsQueryable() .OrderByDescending(m => m.Date) .Select(m => MusicShort.FromMusic(m)) .Page(page ?? 1)); }
public object Latest( [FromQuery][Range(1, 10000)] int?page, [FromServices] AppDbContext context) { var musics = from m in context.Musics.Include(m => m.Uploader) where !m.Deleted orderby m.Date descending select MusicShort.FromMusic(m); return(musics.Page(page ?? 1)); }
public object Search( [FromQuery][Required] string key, [FromQuery][Range(1, 10000)] int?page, [FromServices] AppDbContext context) { var musics = from m in context.Musics.Include(m => m.Uploader) where (m.Artist.Contains(key) || m.ArtistUnicode.Contains(key) || m.Title.Contains(key) || m.TitleUnicode.Contains(key) || m.Description.Contains(key)) && !m.Deleted select MusicShort.FromMusic(m); return(musics.Page(page ?? 1)); }