public async Task <object> MyMaps(
            [FromQuery][Range(1, 10000)] int?page)
        {
            var user = await userManager.GetUserAsync(User);

            return(user.UploadedMaps.AsQueryable()
                   .OrderByDescending(m => m.Date)
                   .Select(m => MapShort.FormMap(m))
                   .Page(page ?? 1));
        }
Beispiel #2
0
        public object Latest(
            [FromQuery][Range(1, 10000)] int?page,
            [FromServices] AppDbContext context)
        {
            var maps =
                from m in context.Maps.IncludeAll()
                where !m.Deleted
                orderby m.Date descending
                select MapShort.FormMap(m);

            return(maps.Page(page ?? 1));
        }
        public async Task <object> Favorites(
            [FromQuery][Range(1, 10000)] int?page)
        {
            var user = await userManager.GetUserAsync(User);

            var favorites =
                from f in user.Favorites.AsQueryable()
                where !f.Map.Deleted
                orderby f.DateTime descending
                select MapShort.FormMap(f.Map);

            return(favorites.Page(page ?? 1));
        }
Beispiel #4
0
        public object Search(
            [FromQuery][Required][MaxLength(50)] string key,
            [FromQuery][Range(1, 10000)] int?page,
            [FromServices] AppDbContext context)
        {
            var maps =
                from m in context.Maps.IncludeAll()
                where (m.Music.Title.Contains(key) || m.Music.TitleUnicode.Contains(key) ||
                       m.Music.Artist.Contains(key) || m.Music.ArtistUnicode.Contains(key) ||
                       m.MapName.Contains(key) || m.Uploader.UserName.Contains(key) || m.Uploader.NickName.Contains(key) ||
                       m.Music.Description.Contains(key) || m.Description.Contains(key)) && !m.Deleted
                orderby m.Date descending
                select MapShort.FormMap(m);

            return(maps.Page(page ?? 1));
        }