Esempio n. 1
0
        public IndexRouteParams(IndexRouteParams index, int?page)
            : this()
        {
            ParamIs.NotNull(() => index);

            artistId    = index.artistId;
            draftsOnly  = index.draftsOnly;
            filter      = index.filter;
            matchMode   = index.matchMode;
            onlyWithPVs = index.onlyWithPVs;
            pageSize    = index.pageSize;
            since       = index.since;
            songType    = index.songType;
            sort        = index.sort;
            view        = index.view;
            this.page   = page;
        }
Esempio n. 2
0
 public Index(PartialFindResult <SongWithAlbumAndPVsContract> result, string filter, NameMatchMode nameMatchMode, SongType songType, string timeFilter, bool onlyWithPVs,
              SongSortRule sortRule, SongViewMode viewMode,
              bool draftsOnly, int page, int pageSize, IndexRouteParams routeParams)
 {
     ArtistId   = routeParams.artistId ?? 0;
     DraftsOnly = draftsOnly;
     Songs      = new StaticPagedList <SongWithAlbumAndPVsContract>(result.Items,
                                                                    page, pageSize, result.TotalCount);
     Filter        = filter;
     NameMatchMode = nameMatchMode;
     SongType      = songType;
     Since         = timeFilter;
     OnlyWithPVs   = onlyWithPVs;
     Sort          = sortRule;
     ViewMode      = viewMode;
     RouteParams   = routeParams;
 }
Esempio n. 3
0
 public Index(PartialFindResult<SongWithAlbumAndPVsContract> result, string filter, NameMatchMode nameMatchMode, SongType songType, string timeFilter, bool onlyWithPVs, 
     SongSortRule sortRule, SongViewMode viewMode,
     bool draftsOnly, int page, int pageSize, IndexRouteParams routeParams)
 {
     ArtistId = routeParams.artistId ?? 0;
     DraftsOnly = draftsOnly;
     Songs = new StaticPagedList<SongWithAlbumAndPVsContract>(result.Items,
         page, pageSize, result.TotalCount);
     Filter = filter;
     NameMatchMode = nameMatchMode;
     SongType = songType;
     Since = timeFilter;
     OnlyWithPVs = onlyWithPVs;
     Sort = sortRule;
     ViewMode = viewMode;
     RouteParams = routeParams;
 }
Esempio n. 4
0
        public IndexRouteParams(IndexRouteParams index, int? page)
            : this()
        {
            ParamIs.NotNull(() => index);

            artistId = index.artistId;
            draftsOnly = index.draftsOnly;
            filter = index.filter;
            hasLyrics = index.hasLyrics;
            matchMode = index.matchMode;
            minScore = index.minScore;
            onlyWithPVs = index.onlyWithPVs;
            pageSize = index.pageSize;
            since = index.since;
            songType = index.songType;
            sort = index.sort;
            userCollectionId = index.userCollectionId;
            view = index.view;
            this.page = page;
        }
Esempio n. 5
0
        public IndexRouteParams(IndexRouteParams index, int?page)
            : this()
        {
            ParamIs.NotNull(() => index);

            artistId         = index.artistId;
            draftsOnly       = index.draftsOnly;
            filter           = index.filter;
            followedByUserId = index.followedByUserId;
            hasLyrics        = index.hasLyrics;
            matchMode        = index.matchMode;
            minScore         = index.minScore;
            onlyWithPVs      = index.onlyWithPVs;
            pageSize         = index.pageSize;
            since            = index.since;
            songType         = index.songType;
            sort             = index.sort;
            userCollectionId = index.userCollectionId;
            view             = index.view;
            this.page        = page;
        }
Esempio n. 6
0
        public ActionResult Index(IndexRouteParams indexParams)
        {
            WebHelper.VerifyUserAgent(Request);

            var pageSize = (indexParams.pageSize.HasValue ? Math.Min(indexParams.pageSize.Value, 30) : 30);
            var page = indexParams.page ?? 1;
            var sortRule = indexParams.sort ?? SongSortRule.Name;
            var timeFilter = DateTimeUtils.ParseFromSimpleString(indexParams.since);
            var filter = indexParams.filter;
            var songType = indexParams.songType ?? SongType.Unspecified;
            var draftsOnly = indexParams.draftsOnly ?? false;
            var matchMode = indexParams.matchMode ?? NameMatchMode.Auto;
            var onlyWithPVs = indexParams.onlyWithPVs ?? false;
            var view = indexParams.view ?? SongViewMode.Details;

            if (matchMode == NameMatchMode.Auto && filter != null && filter.Length <= 2)
                matchMode = NameMatchMode.StartsWith;

            var queryParams = new SongQueryParams(filter,
                songType != SongType.Unspecified ? new[] { songType } : new SongType[] { },
                (page - 1) * pageSize, pageSize, draftsOnly, true, matchMode, sortRule, false, false, null) {

                TimeFilter = timeFilter,
                OnlyWithPVs = onlyWithPVs,
                ArtistId = indexParams.artistId ?? 0
            };

            var result = Service.FindWithAlbum(queryParams, view == SongViewMode.Preview);

            if (page == 1 && result.TotalCount == 1 && result.Items.Length == 1) {
                return RedirectToAction("Details", new { id = result.Items[0].Id });
            }

            SetSearchEntryType(EntryType.Song);
            var model = new Index(result, filter, matchMode, songType, indexParams.since, onlyWithPVs, sortRule, view, draftsOnly, page, pageSize, indexParams);

            return View(model);
        }
Esempio n. 7
0
        public FeedResult Feed(IndexRouteParams indexParams)
        {
            WebHelper.VerifyUserAgent(Request);

            var pageSize = (indexParams.pageSize.HasValue ? Math.Min(indexParams.pageSize.Value, 30) : 30);
            var sortRule = indexParams.sort ?? SongSortRule.Name;
            var timeFilter = DateTimeUtils.ParseFromSimpleString(indexParams.since);
            var filter = indexParams.filter;
            var songType = indexParams.songType ?? SongType.Unspecified;
            var draftsOnly = indexParams.draftsOnly ?? false;
            var matchMode = indexParams.matchMode ?? NameMatchMode.Auto;
            var onlyWithPVs = indexParams.onlyWithPVs ?? false;

            var queryParams = new SongQueryParams(filter,
                songType != SongType.Unspecified ? new[] { songType } : new SongType[] { },
                0, pageSize, draftsOnly, false, matchMode, sortRule, false, false, null) {

                    TimeFilter = timeFilter,
                    OnlyWithPVs = onlyWithPVs,
                    ArtistId = indexParams.artistId ?? 0,
                };

            var result = Service.FindWithThumbPreferNotNico(queryParams);

            var fac = new SongFeedFactory();
            var feed = fac.Create(result.Items,
                VocaUriBuilder.CreateAbsolute(Url.Action("Index", indexParams)),
                song => RenderPartialViewToString("SongItem", song),
                song => Url.Action("Details", new { id = song.Id }));

            return new FeedResult(new Atom10FeedFormatter(feed));
        }
Esempio n. 8
0
 public ActionResult Index(IndexRouteParams indexParams)
 {
     return RedirectToAction("Index", "Search", new SearchRouteParams {
         searchType = EntryType.Song, filter = indexParams.filter, sort = indexParams.sort,
         songType = indexParams.songType, onlyWithPVs = indexParams.onlyWithPVs, artistId = indexParams.artistId
     });
 }