// // GET: /Event/ public ActionResult Index() { var queryParams = new EventQueryParams { AfterDate = DateTime.Now.AddDays(-2), Paging = new PagingProperties(0, 15, false), SortRule = EventSortRule.Date, SortDirection = SortDirection.Ascending }; var events = queries.Find(e => new ReleaseEventForApiContract(e, PermissionContext.LanguagePreference, ReleaseEventOptionalFields.AdditionalNames | ReleaseEventOptionalFields.MainPicture | ReleaseEventOptionalFields.Series | ReleaseEventOptionalFields.Venue, thumbPersister), queryParams); return(View(events.Items)); }
public PartialFindResult <ReleaseEventForApiContract> GetList( string query = "", NameMatchMode nameMatchMode = NameMatchMode.Auto, int seriesId = 0, DateTime?afterDate = null, DateTime?beforeDate = null, int start = 0, int maxResults = defaultMax, bool getTotalCount = false, EventSortRule sort = EventSortRule.Name, ReleaseEventOptionalFields fields = ReleaseEventOptionalFields.None ) { var textQuery = SearchTextQuery.Create(query, nameMatchMode); return(queries.Find(e => new ReleaseEventForApiContract(e, fields), textQuery, seriesId, afterDate, beforeDate, start, maxResults, getTotalCount, sort)); }
public PartialFindResult <ReleaseEventForApiContract> GetList( string query = "", NameMatchMode nameMatchMode = NameMatchMode.Auto, int seriesId = 0, DateTime?afterDate = null, DateTime?beforeDate = null, EventCategory category = EventCategory.Unspecified, int?userCollectionId = null, [FromQuery(Name = "tagId[]")] int[] tagId = null, bool childTags = false, [FromQuery(Name = "artistId[]")] int[] artistId = null, bool childVoicebanks = false, bool includeMembers = false, EntryStatus?status = null, int start = 0, int maxResults = DefaultMax, bool getTotalCount = false, EventSortRule sort = EventSortRule.Name, ReleaseEventOptionalFields fields = ReleaseEventOptionalFields.None, ContentLanguagePreference lang = ContentLanguagePreference.Default ) { var textQuery = SearchTextQuery.Create(query, nameMatchMode); var queryParams = new EventQueryParams { TextQuery = textQuery, SeriesId = seriesId, AfterDate = afterDate, BeforeDate = beforeDate, Category = category, UserId = userCollectionId ?? 0, ArtistIds = new EntryIdsCollection(artistId), ChildVoicebanks = childVoicebanks, IncludeMembers = includeMembers, ChildTags = childTags, TagIds = tagId, EntryStatus = status, Paging = new PagingProperties(start, maxResults, getTotalCount), SortRule = sort }; return(_queries.Find(e => new ReleaseEventForApiContract(e, lang, fields, _thumbPersister), queryParams)); }
private ActionResult TryRedirect(string filter, EntryType searchType) { var textQuery = SearchTextQuery.Create(filter); var artistTextQuery = ArtistSearchTextQuery.Create(filter); switch (searchType) { case EntryType.Undefined: { var result = entryQueries.GetList(filter, null, null, false, null, 0, 1, true, EntrySortRule.Name, NameMatchMode.Auto, Model.DataContracts.Api.EntryOptionalFields.None, Model.Domain.Globalization.ContentLanguagePreference.Default, false, true); if (result.TotalCount == 1) { var item = result.Items.First(); var entryType = item.EntryType; var entryId = item.Id; if (entryType == EntryType.Album) { return(RedirectToAlbum(entryId)); } if (entryType == EntryType.Artist) { return(RedirectToArtist(entryId)); } if (entryType == EntryType.Song) { return(RedirectToSong(entryId)); } if (entryType == EntryType.Tag) { return(RedirectToTag(entryId, item.UrlSlug)); } } } break; case EntryType.Artist: var artist = artistService.FindArtists(new ArtistQueryParams(artistTextQuery, null, 0, 2, false, ArtistSortRule.None, false)); if (artist.Items.Length == 1) { return(RedirectToArtist(artist.Items[0].Id)); } break; case EntryType.Album: var album = albumService.Find(new AlbumQueryParams(textQuery, DiscType.Unknown, 0, 2, false, AlbumSortRule.None, false)); if (album.Items.Length == 1) { return(RedirectToAlbum(album.Items[0].Id)); } break; case EntryType.ReleaseEvent: var ev = eventQueries.Find(s => s.Id, textQuery, 0, null, null, 0, 2, false, EventSortRule.Name); if (ev.Items.Length == 1) { return(RedirectToReleaseEvent(ev.Items[0])); } return(RedirectToAction("EventsBySeries", "Event")); case EntryType.Song: var song = songService.Find(new SongQueryParams(textQuery, null, 0, 2, false, SongSortRule.None, false, false, null)); if (song.Items.Length == 1) { return(RedirectToSong(song.Items[0].Id)); } break; case EntryType.SongList: var list = songListQueries.Find(s => s.Id, textQuery, null, 0, 2, false, SongListSortRule.Name); if (list.Items.Length == 1) { return(RedirectToSongList(list.Items[0])); } return(RedirectToAction("Featured", "SongList")); case EntryType.Tag: var tags = tagQueries.Find(new TagQueryParams(new CommonSearchParams(textQuery, true, true), PagingProperties.FirstPage(2)), TagOptionalFields.None, WebHelper.IsSSL(Request), permissionContext.LanguagePreference); if (tags.Items.Length == 1) { return(RedirectToTag(tags.Items.First().Id, tags.Items.First().Name)); } break; default: { var action = "Index"; var controller = searchType.ToString(); return(RedirectToAction(action, controller, new { filter })); } } return(null); }
private ActionResult TryRedirect(string filter, EntryType searchType) { var textQuery = SearchTextQuery.Create(filter); var artistTextQuery = ArtistSearchTextQuery.Create(filter); switch (searchType) { case EntryType.Undefined: { var result = _entryQueries.GetList(filter, null, null, false, null, null, 0, 1, true, EntrySortRule.Name, NameMatchMode.Auto, Model.DataContracts.Api.EntryOptionalFields.None, Model.Domain.Globalization.ContentLanguagePreference.Default, searchTags: true, searchEvents: true); if (result.TotalCount == 1) { var item = result.Items.First(); var entryId = item.Id; switch (item.EntryType) { case EntryType.Album: return(RedirectToAlbum(entryId)); case EntryType.Artist: return(RedirectToArtist(entryId)); case EntryType.ReleaseEvent: return(RedirectToReleaseEvent(entryId, item.UrlSlug)); case EntryType.Song: return(RedirectToSong(entryId)); case EntryType.Tag: return(RedirectToTag(entryId, item.UrlSlug)); } } } break; case EntryType.Artist: var artist = _artistService.FindArtists(new ArtistQueryParams(artistTextQuery, null, 0, 2, false, ArtistSortRule.None, false) { LanguagePreference = PermissionContext.LanguagePreference }); if (artist.Items.Length == 1) { return(RedirectToArtist(artist.Items[0].Id)); } break; case EntryType.Album: var album = _albumService.Find(new AlbumQueryParams(textQuery, DiscType.Unknown, 0, 2, false, AlbumSortRule.None, false) { LanguagePreference = PermissionContext.LanguagePreference }); if (album.Items.Length == 1) { return(RedirectToAlbum(album.Items[0].Id)); } break; case EntryType.ReleaseEvent: var queryParams = new EventQueryParams { TextQuery = textQuery, Paging = new PagingProperties(0, 2, false) }; var ev = _eventQueries.Find(s => new { s.Id, s.UrlSlug }, queryParams); if (ev.Items.Length == 1) { return(RedirectToReleaseEvent(ev.Items[0].Id, ev.Items[0].UrlSlug)); } break; case EntryType.Song: var song = _songService.Find(new SongQueryParams(textQuery, null, 0, 2, false, SongSortRule.None, false, false, null) { LanguagePreference = PermissionContext.LanguagePreference }); if (song.Items.Length == 1) { return(RedirectToSong(song.Items[0].Id)); } break; case EntryType.SongList: var list = _songListQueries.Find(s => s.Id, new SongListQueryParams { TextQuery = textQuery, Paging = new PagingProperties(0, 2, false), SortRule = SongListSortRule.Name }); if (list.Items.Length == 1) { return(RedirectToSongList(list.Items[0])); } return(RedirectToAction("Featured", "SongList")); case EntryType.Tag: var tags = _tagQueries.Find(new TagQueryParams(new CommonSearchParams(textQuery, true, true), PagingProperties.FirstPage(2)) { AllowChildren = true, LanguagePreference = PermissionContext.LanguagePreference }, TagOptionalFields.None, _permissionContext.LanguagePreference); if (tags.Items.Length == 1) { return(RedirectToTag(tags.Items.First().Id, tags.Items.First().Name)); } break; default: { var action = "Index"; var controller = searchType.ToString(); return(RedirectToAction(action, controller, new { filter })); } } return(null); }