// // 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, 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)); }
public PartialFindResult <TResult> Find <TResult>(Func <ReleaseEvent, TResult> fac, EventQueryParams queryParams) { return(HandleQuery(ctx => { var q = ctx.Query() .WhereNotDeleted() .WhereHasArtists(queryParams.ArtistIds, queryParams.ChildVoicebanks, queryParams.IncludeMembers) .WhereHasCategory(queryParams.Category) .WhereHasName(queryParams.TextQuery) .WhereHasSeries(queryParams.SeriesId) .WhereStatusIs(queryParams.EntryStatus) .WhereDateIsBetween(queryParams.AfterDate, queryParams.BeforeDate) .WhereInUserCollection(queryParams.UserId) .WhereHasTags(queryParams.TagIds, queryParams.ChildTags); var entries = q .OrderBy(queryParams.SortRule, LanguagePreference, queryParams.SortDirection) .Paged(queryParams.Paging) .ToArray() .Select(fac) .ToArray(); var count = 0; if (queryParams.Paging != null && queryParams.Paging.GetTotalCount) { count = q.Count(); } return new PartialFindResult <TResult>(entries, count); })); }
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); }