public void GetDetails_RecentEvents() { void AssertContainsEvent(TagDetailsContract details, ReleaseEvent releaseEvent) { Assert.IsTrue(details.Events.Any(e => e.Id == releaseEvent.Id), "Contains " + releaseEvent); } var standaloneEvent = CreateEntry.ReleaseEvent("Miku party"); var otherEvent = CreateEntry.ReleaseEvent("Magical Mirai"); var eventSeries = CreateEntry.EventSeries("VocaTRAVers"); var seriesUsage = repository.Save(new EventSeriesTagUsage(eventSeries, tag)); eventSeries.Tags.Usages.Add(seriesUsage); tag.AllEventSeriesTagUsages.Add(seriesUsage); var oldSeriesEvent = CreateEntry.ReleaseEvent("VocaTRAVers 1", date: DateTime.Now.AddDays(-30)); oldSeriesEvent.SetSeries(eventSeries); var recentSeriesEvent = CreateEntry.ReleaseEvent("VocaTRAVers 2", date: DateTime.Now); recentSeriesEvent.SetSeries(eventSeries); repository.Save(standaloneEvent, otherEvent, oldSeriesEvent, recentSeriesEvent); repository.Save(eventSeries); repository.Save(CreateTagUsage(tag, standaloneEvent), CreateTagUsage(tag, oldSeriesEvent), CreateTagUsage(tag, recentSeriesEvent)); var result = queries.GetDetails(tag.Id); Assert.AreEqual(2, result.EventCount, "EventCount"); Assert.AreEqual(2, result.Events.Length, "Events.Length"); Assert.AreEqual(1, result.EventSeriesCount, "EventSeriesCount"); Assert.AreEqual(1, result.EventSeries.Length, "EventSeries.Length"); AssertContainsEvent(result, standaloneEvent); AssertContainsEvent(result, recentSeriesEvent); Assert.IsTrue(result.EventSeries.Any(e => e.Id == eventSeries.Id), "Contains " + eventSeries); }
public ActionResult DetailsById(int id = invalidId, string slug = null) { if (id == invalidId) { return(NoId()); } // TODO: write test for null slug slug = slug ?? string.Empty; var tagName = queries.LoadTag(id, t => t.UrlSlug ?? string.Empty); if (slug != tagName) { return(RedirectToActionPermanent("DetailsById", new { id, slug = tagName })); } var contract = queries.GetDetails(id); var prop = PageProperties; var thumbUrl = Url.EntryImageOld(contract.Thumb, ImageSize.Original); if (!string.IsNullOrEmpty(thumbUrl)) { PageProperties.OpenGraph.Image = thumbUrl; } prop.Description = markdownParser.GetPlainText(contract.Description.EnglishOrOriginal); return(RenderDetails(contract)); }
public ActionResult Details(string id) { if (string.IsNullOrEmpty(id)) { return(NoId()); } var contract = queries.GetDetails(id); if (contract == null) { return(HttpNotFound()); } return(View(contract)); }