Exemplo n.º 1
0
        //
        // GET: /Album/

        public ActionResult Index(IndexRouteParams routeParams)
        {
            WebHelper.VerifyUserAgent(Request);

            var filter     = routeParams.filter;
            var page       = routeParams.page;
            var draftsOnly = routeParams.draftsOnly;
            var dType      = routeParams.discType ?? DiscType.Unknown;
            var matchMode  = routeParams.matchMode ?? NameMatchMode.Auto;
            var sortRule   = routeParams.sort ?? AlbumSortRule.Name;
            var viewMode   = routeParams.view ?? EntryViewMode.Details;

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

            var queryParams = new AlbumQueryParams(filter, dType, ((page ?? 1) - 1) * 30, 30, draftsOnly ?? false,
                                                   true, moveExactToTop: false, sortRule: sortRule, nameMatchMode: matchMode);

            var result = Service.Find(queryParams);

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

            var model = new Index(result, filter, dType, sortRule, viewMode, page, draftsOnly, routeParams);

            SetSearchEntryType(EntryType.Album);

            return(View(model));
        }
Exemplo n.º 2
0
        public void SetUp()
        {
            querySource = new QuerySourceList();

            artist = new Artist(TranslatedString.Create("XenonP"))
            {
                Id = 64
            };
            querySource.Add(artist);

            album = new Album(new LocalizedString("Synthesis", ContentLanguageSelection.English))
            {
                Id = 1, DiscType = DiscType.Album, CreateDate = new DateTime(2011, 1, 16)
            };
            AddAlbum(album);

            albumWithArtist = new Album(new LocalizedString("DIVINE", ContentLanguageSelection.English))
            {
                Id = 1010, DiscType = DiscType.Unknown, RatingAverage = 4.5, CreateDate = new DateTime(2012, 1, 15)
            };
            albumWithArtist.AddArtist(artist);
            AddAlbum(albumWithArtist);

            queryParams = new AlbumQueryParams();

            search = new Model.Service.Search.AlbumSearch.AlbumSearch(querySource, ContentLanguagePreference.Default);
        }
Exemplo n.º 3
0
        public PartialFindResult <AlbumContract> Find(
            string query, DiscType discType, int start, int maxResults, bool draftsOnly, bool getTotalCount,
            NameMatchMode nameMatchMode = NameMatchMode.Auto, AlbumSortRule sortRule = AlbumSortRule.Name, bool moveExactToTop = false)
        {
            var queryParams = new AlbumQueryParams(query, discType, start, maxResults, draftsOnly, getTotalCount, nameMatchMode, sortRule, moveExactToTop);

            return(Find(queryParams));
        }
Exemplo n.º 4
0
        public PartialFindResult <AlbumContract> Find(
            SearchTextQuery textQuery, DiscType discType, int start, int maxResults, bool getTotalCount,
            AlbumSortRule sortRule = AlbumSortRule.Name, bool moveExactToTop = false)
        {
            var queryParams = new AlbumQueryParams(textQuery, discType, start, maxResults, getTotalCount, sortRule, moveExactToTop);

            return(Find(queryParams));
        }
Exemplo n.º 5
0
        public ActionResult Index(string query, DiscType discType = DiscType.Unknown,
                                  int start = 0, bool getTotalCount = false, AlbumSortRule sort = AlbumSortRule.Name,
                                  NameMatchMode nameMatchMode = NameMatchMode.Exact, DataFormat format = DataFormat.Auto)
        {
            var queryParams = new AlbumQueryParams(query, discType, start, maxResults, false, getTotalCount, nameMatchMode, sort);

            var entries = Service.Find(a => new AlbumForApiContract(a, LoginManager.LanguagePreference), queryParams);

            return(Object(entries, format));
        }
Exemplo n.º 6
0
        public void QueryNameWords_SkipFirstPage()
        {
            CreateName(_album, "Synthesis Miku", ContentLanguageSelection.Unspecified);
            CreateName(_albumWithArtist, "DIVINE Miku", ContentLanguageSelection.Unspecified);

            _queryParams = _queryParams with
            {
                Common = _queryParams.Common with {
                    TextQuery = SearchTextQuery.Create("Miku Miku")
                },
Exemplo n.º 7
0
        public PartialFindResult <AlbumForApiContract> GetList(
            string query               = "",
            DiscType discTypes         = DiscType.Unknown,
            [FromUri] string[] tagName = null,
            [FromUri] int[] tagId      = null,
            bool childTags             = false,
            [FromUri] int[] artistId   = null,
            ArtistAlbumParticipationStatus artistParticipationStatus = ArtistAlbumParticipationStatus.Everything,
            bool childVoicebanks       = false,
            bool includeMembers        = false,
            string barcode             = null,
            EntryStatus?status         = null,
            DateTime?releaseDateAfter  = null,
            DateTime?releaseDateBefore = null,
            [FromUri] AdvancedSearchFilter[] advancedFilters = null,
            int start                      = 0,
            int maxResults                 = defaultMax,
            bool getTotalCount             = false,
            AlbumSortRule?sort             = null,
            bool preferAccurateMatches     = false,
            bool deleted                   = false,
            NameMatchMode nameMatchMode    = NameMatchMode.Exact,
            AlbumOptionalFields fields     = AlbumOptionalFields.None,
            ContentLanguagePreference lang = ContentLanguagePreference.Default)
        {
            var textQuery = SearchTextQuery.Create(query, nameMatchMode);

            var queryParams = new AlbumQueryParams(textQuery, discTypes, start, Math.Min(maxResults, absoluteMax), getTotalCount, sort ?? AlbumSortRule.Name, preferAccurateMatches)
            {
                ArtistParticipation =
                {
                    ArtistIds       = artistId,
                    Participation   = artistParticipationStatus,
                    ChildVoicebanks = childVoicebanks,
                    IncludeMembers  = includeMembers
                },
                Tags               = tagName,
                TagIds             = tagId,
                ChildTags          = childTags,
                Barcode            = barcode,
                Deleted            = deleted,
                ReleaseDateAfter   = releaseDateAfter,
                ReleaseDateBefore  = releaseDateBefore,
                AdvancedFilters    = advancedFilters,
                LanguagePreference = lang
            };

            queryParams.Common.EntryStatus = status;

            var ssl = WebHelper.IsSSL(Request);

            var entries = service.Find(a => new AlbumForApiContract(a, null, lang, thumbPersister, ssl, fields, SongOptionalFields.None), queryParams);

            return(entries);
        }
Exemplo n.º 8
0
        public PartialFindResult <T> Find <T>(Func <Album, T> fac, AlbumQueryParams queryParams)
            where T : class
        {
            ParamIs.NotNull(() => queryParams);

            return(HandleQuery(session => {
                var result = Find(session, queryParams);

                return new PartialFindResult <T>(result.Items.Select(fac).ToArray(),
                                                 result.TotalCount, result.Term, result.FoundExactMatch);
            }));
        }
Exemplo n.º 9
0
        public void ListSortAdditionDate()
        {
            _queryParams = _queryParams with {
                SortRule = AlbumSortRule.AdditionDate
            };

            var result = Find();

            result.Items.Length.Should().Be(2, "2 results");
            result.TotalCount.Should().Be(2, "total result count");
            result.Items[0].DefaultName.Should().Be("DIVINE");
            result.Items[1].DefaultName.Should().Be("Synthesis");
        }
Exemplo n.º 10
0
        public PartialViewResult AlbumsPaged(int id, int?page)
        {
            var pageIndex   = (page - 1) ?? 0;
            var queryParams = new AlbumQueryParams {
                Paging   = PagingProperties.CreateFromPage(pageIndex, entriesPerPage, true),
                SortRule = AlbumSortRule.Name,
                ArtistId = id
            };
            var result = Services.Albums.Find(queryParams);
            var data   = new PagingData <AlbumContract>(result.Items.ToPagedList(pageIndex, entriesPerPage, result.TotalCount), id, "AlbumsPaged", "ui-tabs-2");

            return(PartialView("PagedAlbums", data));
        }
Exemplo n.º 11
0
        public ActionResult Index(string query, DiscType discType = DiscType.Unknown,
                                  int start = 0, bool getTotalCount = false, AlbumSortRule sort = AlbumSortRule.Name,
                                  NameMatchMode nameMatchMode    = NameMatchMode.Exact,
                                  bool includeArtists            = true, bool includeNames = true, bool includePVs = false, bool includeTags = true, bool includeWebLinks = false,
                                  DataFormat format              = DataFormat.Auto,
                                  ContentLanguagePreference lang = ContentLanguagePreference.Default)
        {
            var queryParams = new AlbumQueryParams(query, discType, start, maxResults, false, getTotalCount, nameMatchMode, sort);

            var entries = Service.Find(a => new AlbumForApiContract(a, null, lang, includeArtists, includeNames, includePVs, includeTags, includeWebLinks), queryParams);

            return(Object(entries, format));
        }
Exemplo n.º 12
0
        public void ListSkip()
        {
            _queryParams = _queryParams with {
                Paging = _queryParams.Paging with {
                    Start = 1
                }
            };

            var result = Find();

            result.Items.Length.Should().Be(1, "1 result");
            result.TotalCount.Should().Be(2, "total result count");
            result.Items[0].Should().Be(_albumWithArtist);
        }
Exemplo n.º 13
0
        public void QueryName()
        {
            _queryParams = _queryParams with {
                Common = _queryParams.Common with {
                    TextQuery = SearchTextQuery.Create("DIVINE")
                }
            };

            var result = Find();

            result.Items.Length.Should().Be(1, "1 result");
            result.TotalCount.Should().Be(1, "total result count");
            result.Items[0].DefaultName.Should().Be("DIVINE");
        }
Exemplo n.º 14
0
        public PartialViewResult AlbumsPaged(int id, ArtistAlbumParticipationStatus?artistParticipation, int?page)
        {
            var pageIndex   = (page - 1) ?? 0;
            var queryParams = new AlbumQueryParams {
                Paging   = PagingProperties.CreateFromPage(pageIndex, entriesPerPage, true),
                SortRule = AlbumSortRule.ReleaseDateWithNulls,
                ArtistId = id,
                ArtistParticipationStatus = artistParticipation ?? ArtistAlbumParticipationStatus.Everything
            };

            var result = Services.Albums.Find(queryParams);

            var target = queryParams.ArtistParticipationStatus == ArtistAlbumParticipationStatus.OnlyCollaborations ? "ui-tabs-3" : "ui-tabs-2";
            var data   = new PagingData <AlbumContract>(result.Items.ToPagedList(pageIndex, entriesPerPage, result.TotalCount), id, "AlbumsPaged", target);

            data.RouteValues = new RouteValueDictionary(new { artistParticipation });

            return(PartialView("PagedAlbums", data));
        }
Exemplo n.º 15
0
        public PartialFindResult <AlbumForApiContract> GetList(
            string query       = "",
            DiscType discTypes = DiscType.Unknown,
            string tag         = null,
            int?artistId       = null,
            ArtistAlbumParticipationStatus artistParticipationStatus = ArtistAlbumParticipationStatus.Everything,
            bool childVoicebanks           = false,
            string barcode                 = null,
            EntryStatus?status             = null,
            int start                      = 0,
            int maxResults                 = defaultMax,
            bool getTotalCount             = false,
            AlbumSortRule?sort             = null,
            bool preferAccurateMatches     = false,
            bool deleted                   = false,
            NameMatchMode nameMatchMode    = NameMatchMode.Exact,
            AlbumOptionalFields fields     = AlbumOptionalFields.None,
            ContentLanguagePreference lang = ContentLanguagePreference.Default)
        {
            var textQuery = SearchTextQuery.Create(query, nameMatchMode);

            var queryParams = new AlbumQueryParams(textQuery, discTypes, start, Math.Min(maxResults, absoluteMax), false, getTotalCount, sort ?? AlbumSortRule.Name, preferAccurateMatches)
            {
                Tag      = tag,
                ArtistId = artistId ?? 0,
                ArtistParticipationStatus = artistParticipationStatus,
                ChildVoicebanks           = childVoicebanks,
                Barcode = barcode,
                Deleted = deleted
            };

            queryParams.Common.EntryStatus = status;

            var ssl = WebHelper.IsSSL(Request);

            var entries = service.Find(a => new AlbumForApiContract(a, null, lang, thumbPersister, ssl, fields), queryParams);

            return(entries);
        }
Exemplo n.º 16
0
// ReSharper restore UnusedMember.Local

        private PartialFindResult <Album> Find(ISession session, AlbumQueryParams queryParams)
        {
            return(new AlbumSearch(new QuerySourceSession(session), LanguagePreference).Find(queryParams));
        }
Exemplo n.º 17
0
 public PartialFindResult <AlbumContract> Find(AlbumQueryParams queryParams)
 {
     return(Find(s => new AlbumContract(s, LanguagePreference), queryParams));
 }
Exemplo n.º 18
0
 private PartialFindResult <Album> Find(ISession session, AlbumQueryParams queryParams)
 {
     return(new AlbumSearch(new NHibernateDatabaseContext(session, PermissionContext), queryParams.LanguagePreference).Find(queryParams));
 }