Browse Source

Show past and upcoming events.

pull/15/head
Halil İbrahim Kalkan 6 years ago
parent
commit
898fa1d980
  1. 11
      eventhub/src/EventHub.Application/Events/EventAppService.cs
  2. 4
      eventhub/src/EventHub.Domain.Shared/Localization/EventHub/en.json
  3. 70
      eventhub/src/EventHub.Web/Pages/Organizations/Profile.cshtml
  4. 31
      eventhub/src/EventHub.Web/Pages/Organizations/Profile.cshtml.cs

11
eventhub/src/EventHub.Application/Events/EventAppService.cs

@ -79,7 +79,16 @@ namespace EventHub.Events
var totalCount = await AsyncExecuter.CountAsync(query);
query = query.PageBy(input).OrderBy(x => x.@event.StartTime);
query = query.PageBy(input);
if (input.MaxDate.HasValue && !input.MinDate.HasValue)
{
query = query.OrderByDescending(x => x.@event.StartTime);
}
else
{
query = query.OrderBy(x => x.@event.StartTime);
}
var items = await AsyncExecuter.ToListAsync(query);
var now = Clock.Now;

4
eventhub/src/EventHub.Domain.Shared/Localization/EventHub/en.json

@ -33,6 +33,8 @@
"EventRegisterSuccessMessage": "We will send a reminder email before the event.",
"EventRegistrationCancelledMessage": "Your event registration has been cancelled.",
"OrganizedBy": "Organized by",
"NoEventOrganizedByThisOrganizationYet": "No event organized by this organization yet!"
"NoEventOrganizedByThisOrganizationYet": "No event organized by this organization yet!",
"Upcoming": "Upcoming",
"Past": "Past"
}
}

70
eventhub/src/EventHub.Web/Pages/Organizations/Profile.cshtml

@ -20,30 +20,56 @@
</abp-column>
</abp-row>
@if (Model.Events.Any())
@if (Model.UpcomingEvents.Any())
{
<h3>Upcoming Events</h3>
<h3>Events</h3>
<abp-row>
@foreach (var eventItem in Model.Events)
{
<abp-column size-lg="_4" size-md="_6">
<abp-card class="mb-3">
<img abp-card-image="Top" src="https://picsum.photos/seed/@eventItem.Id.ToString()/400/160?blur=8" alt="@eventItem.Title"/>
<abp-card-body>
<abp-card-title>@eventItem.Title</abp-card-title>
<abp-card-subtitle>
@EventDateHelper.GetDateRangeText(eventItem.StartTime, eventItem.EndTime)
</abp-card-subtitle>
<abp-card-text>
@eventItem.Description.TruncateWithPostfix(100)
</abp-card-text>
<a abp-button="Primary" href="@Url.Page("/Events/Detail", new { url = eventItem.Url })"> @L["SeeEvent"]</a>
</abp-card-body>
</abp-card>
</abp-column>
}
</abp-row>
<abp-tabs tab-style="Pill">
<abp-tab title="@($"{L["Upcoming"].Value} ({Model.UpcomingEventTotalCount})")">
<abp-row class="mt-3">
@foreach (var eventItem in Model.UpcomingEvents)
{
<abp-column size-lg="_4" size-md="_6">
<abp-card class="mb-3">
<img abp-card-image="Top" src="https://picsum.photos/seed/@eventItem.Id.ToString()/400/160?blur=8" alt="@eventItem.Title"/>
<abp-card-body>
<abp-card-title>@eventItem.Title</abp-card-title>
<abp-card-subtitle>
@EventDateHelper.GetDateRangeText(eventItem.StartTime, eventItem.EndTime)
</abp-card-subtitle>
<abp-card-text>
@eventItem.Description.TruncateWithPostfix(100)
</abp-card-text>
<a abp-button="Primary" href="@Url.Page("/Events/Detail", new {url = eventItem.Url})"> @L["SeeEvent"]</a>
</abp-card-body>
</abp-card>
</abp-column>
}
</abp-row>
</abp-tab>
<abp-tab title="@($"{L["Past"].Value} ({Model.PastEventTotalCount})")">
<abp-row class="mt-3">
@foreach (var eventItem in Model.PastEvents)
{
<abp-column size-lg="_4" size-md="_6">
<abp-card class="mb-3">
<img abp-card-image="Top" src="https://picsum.photos/seed/@eventItem.Id.ToString()/400/160?blur=8" alt="@eventItem.Title"/>
<abp-card-body>
<abp-card-title>@eventItem.Title</abp-card-title>
<abp-card-subtitle>
@EventDateHelper.GetDateRangeText(eventItem.StartTime, eventItem.EndTime)
</abp-card-subtitle>
<abp-card-text>
@eventItem.Description.TruncateWithPostfix(100)
</abp-card-text>
<a abp-button="Primary" href="@Url.Page("/Events/Detail", new {url = eventItem.Url})"> @L["SeeEvent"]</a>
</abp-card-body>
</abp-card>
</abp-column>
}
</abp-row>
</abp-tab>
</abp-tabs>
}
else
{

31
eventhub/src/EventHub.Web/Pages/Organizations/Profile.cshtml.cs

@ -12,7 +12,11 @@ namespace EventHub.Web.Pages.Organizations
public string Name { get; set; }
public OrganizationProfileDto Organization { get; set; }
public IReadOnlyList<EventInListDto> Events { get; private set; }
public IReadOnlyList<EventInListDto> UpcomingEvents { get; private set; }
public long UpcomingEventTotalCount { get; private set; }
public IReadOnlyList<EventInListDto> PastEvents { get; private set; }
public long PastEventTotalCount { get; private set; }
private readonly IEventAppService _eventAppService;
private readonly IOrganizationAppService _organizationAppService;
@ -26,9 +30,19 @@ namespace EventHub.Web.Pages.Organizations
}
public async Task OnGetAsync()
{
await GetProfileAsync();
await GetUpcomingEventsAsync();
await GetPastEventsAsync();
}
private async Task GetProfileAsync()
{
Organization = await _organizationAppService.GetProfileAsync(Name);
}
private async Task GetUpcomingEventsAsync()
{
var result = await _eventAppService.GetListAsync(
new EventListFilterDto
{
@ -36,8 +50,21 @@ namespace EventHub.Web.Pages.Organizations
OrganizationId = Organization.Id
}
);
UpcomingEvents = result.Items;
UpcomingEventTotalCount = result.TotalCount;
}
Events = result.Items;
private async Task GetPastEventsAsync()
{
var result = await _eventAppService.GetListAsync(
new EventListFilterDto
{
MaxDate = Clock.Now,
OrganizationId = Organization.Id
}
);
PastEvents = result.Items;
PastEventTotalCount = result.TotalCount;
}
}
}

Loading…
Cancel
Save