Browse Source

Show events of the organization.

pull/15/head
Halil İbrahim Kalkan 6 years ago
parent
commit
1cdb50aba0
  1. 4
      eventhub/src/EventHub.Application.Contracts/Events/EventListFilterDto.cs
  2. 9
      eventhub/src/EventHub.Application/Events/EventAppService.cs
  3. 3
      eventhub/src/EventHub.Domain.Shared/Localization/EventHub/en.json
  4. 8
      eventhub/src/EventHub.Web/Pages/Events/Detail.cshtml
  5. 26
      eventhub/src/EventHub.Web/Pages/Events/EventDateHelper.cs
  6. 8
      eventhub/src/EventHub.Web/Pages/Index.cshtml
  7. 60
      eventhub/src/EventHub.Web/Pages/Organizations/Profile.cshtml
  8. 24
      eventhub/src/EventHub.Web/Pages/Organizations/Profile.cshtml.cs

4
eventhub/src/EventHub.Application.Contracts/Events/EventListFilterDto.cs

@ -9,9 +9,11 @@ namespace EventHub.Events
public DateTime? MaxDate { get; set; }
public Guid? OrganizationId { get; set; }
public EventListFilterDto()
{
MaxResultCount = 20;
}
}
}
}

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

@ -64,12 +64,17 @@ namespace EventHub.Events
if (input.MinDate.HasValue)
{
query = query.Where(i => i.@event.EndTime >= input.MinDate);
query = query.Where(i => i.@event.EndTime >= input.MinDate.Value);
}
if (input.MaxDate.HasValue)
{
query = query.Where(i => i.@event.EndTime <= input.MaxDate);
query = query.Where(i => i.@event.EndTime <= input.MaxDate.Value);
}
if (input.OrganizationId.HasValue)
{
query = query.Where(i => i.@event.OrganizationId == input.OrganizationId.Value);
}
var totalCount = await AsyncExecuter.CountAsync(query);

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

@ -32,6 +32,7 @@
"EventRegisterSuccessMessageTitle": "Thanks for registering!",
"EventRegisterSuccessMessage": "We will send a reminder email before the event.",
"EventRegistrationCancelledMessage": "Your event registration has been cancelled.",
"OrganizedBy": "Organized by"
"OrganizedBy": "Organized by",
"NoEventOrganizedByThisOrganizationYet": "No event organized by this organization yet!"
}
}

8
eventhub/src/EventHub.Web/Pages/Events/Detail.cshtml

@ -1,6 +1,7 @@
@page "/events/{url}"
@inject IHtmlLocalizer<EventHubResource> L
@using EventHub.Localization
@using EventHub.Web.Pages.Events
@using EventHub.Web.Pages.Events.Components.AttendeesArea
@using EventHub.Web.Pages.Events.Components.RegistrationArea
@using Microsoft.AspNetCore.Mvc.Localization
@ -10,10 +11,11 @@
<abp-card class="mb-3">
<img abp-card-image="Top" src="https://picsum.photos/seed/@Model.Event.Id.ToString()/400/160?blur=8" alt="@Model.Event.Title"/>
<abp-card-body>
<abp-card-title>@Model.Event.Title</abp-card-title>
<abp-card-title>
<h2>@Model.Event.Title</h2>
</abp-card-title>
<abp-card-subtitle>
@Model.Event.StartTime.ToLongDateString(),
@Model.Event.StartTime.ToString("hh:mm") <br/>
@EventDateHelper.GetDateRangeText(Model.Event.StartTime, Model.Event.EndTime) <br/>
<span class="text-muted">@L["OrganizedBy"]</span> <a href="@Url.Page("/Organizations/Profile", new {name = Model.Event.OrganizationName})">@Model.Event.OrganizationDisplayName</a>
</abp-card-subtitle>
<abp-card-text class="mt-3">

26
eventhub/src/EventHub.Web/Pages/Events/EventDateHelper.cs

@ -0,0 +1,26 @@
using System;
using System.Text;
namespace EventHub.Web.Pages.Events
{
public static class EventDateHelper
{
public static string GetDateRangeText(DateTime startTime, DateTime endTime)
{
var sb = new StringBuilder();
sb.Append(startTime.ToLongDateString());
sb.Append(", ");
sb.Append(startTime.ToString("hh:mm"));
sb.Append(" - ");
if (startTime.Day != endTime.Day)
{
sb.Append(endTime.ToLongDateString());
sb.Append(", ");
}
sb.Append(endTime.ToString("hh:mm"));
return sb.ToString();
}
}
}

8
eventhub/src/EventHub.Web/Pages/Index.cshtml

@ -2,6 +2,7 @@
@model EventHub.Web.Pages.IndexModel
@using Microsoft.AspNetCore.Mvc.Localization
@using EventHub.Localization
@using EventHub.Web.Pages.Events
@inject IHtmlLocalizer<EventHubResource> L
@section styles {
@ -26,8 +27,11 @@
<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>@eventItem.StartTime.ToLongDateString(), @eventItem.StartTime.ToString("hh:mm")</abp-card-subtitle>
<abp-card-text>
<abp-card-subtitle>
@EventDateHelper.GetDateRangeText(eventItem.StartTime, eventItem.EndTime) <br/>
<span class="text-muted">@L["OrganizedBy"]</span> <a href="@Url.Page("/Organizations/Profile", new {name = eventItem.OrganizationName})">@eventItem.OrganizationDisplayName</a>
</abp-card-subtitle>
<abp-card-text class="mt-2">
@eventItem.Description.TruncateWithPostfix(100)
</abp-card-text>
<a abp-button="Primary" href="@Url.Page("/Events/Detail", new { url = eventItem.Url })"> @L["SeeEvent"]</a>

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

@ -1,19 +1,53 @@
@page "/organizations/{name}"
@inject IHtmlLocalizer<EventHubResource> L
@using EventHub.Localization
@using EventHub.Web.Pages.Events
@using Microsoft.AspNetCore.Mvc.Localization
@model EventHub.Web.Pages.Organizations.ProfilePageModel
<h1>@Model.Organization.DisplayName <small class="text-muted">@Model.Organization.Name</small></h1>
<img class="img-fluid mb-3" src="https://picsum.photos/seed/@Model.Name/1920/400?blur=8">
<p class="lead">
@Model.Organization.Description
</p>
<abp-row>
<abp-column size-lg="_12">
<abp-card class="mb-3">
<img abp-card-image="Top" src="https://picsum.photos/seed/@Model.Name/1920/400?blur=8" alt="@Model.Organization.DisplayName"/>
<abp-card-body>
<abp-card-title>
<h2>@Model.Organization.DisplayName</h2>
</abp-card-title>
<abp-card-text class="mt-3">
@Model.Organization.Description
</abp-card-text>
</abp-card-body>
</abp-card>
</abp-column>
</abp-row>
<abp-tabs>
<abp-tab title="@L["Events"].Value">
TODO
</abp-tab>
<abp-tab title="@L["Members"].Value">
TODO
</abp-tab>
</abp-tabs>
@if (Model.Events.Any())
{
<h3>Upcoming 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>
}
else
{
<abp-alert alert-type="Info">
@L["NoEventOrganizedByThisOrganizationYet"]
</abp-alert>
}

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

@ -1,27 +1,43 @@
using System.Threading.Tasks;
using System.Collections.Generic;
using System.Threading.Tasks;
using EventHub.Events;
using EventHub.Organizations;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
namespace EventHub.Web.Pages.Organizations
{
public class ProfilePageModel : PageModel
public class ProfilePageModel : EventHubPageModel
{
[BindProperty(SupportsGet = true)]
public string Name { get; set; }
public OrganizationProfileDto Organization { get; set; }
public IReadOnlyList<EventInListDto> Events { get; private set; }
private readonly IEventAppService _eventAppService;
private readonly IOrganizationAppService _organizationAppService;
public ProfilePageModel(IOrganizationAppService organizationAppService)
public ProfilePageModel(
IOrganizationAppService organizationAppService,
IEventAppService eventAppService)
{
_organizationAppService = organizationAppService;
_eventAppService = eventAppService;
}
public async Task OnGetAsync()
{
Organization = await _organizationAppService.GetProfileAsync(Name);
var result = await _eventAppService.GetListAsync(
new EventListFilterDto
{
MinDate = Clock.Now,
OrganizationId = Organization.Id
}
);
Events = result.Items;
}
}
}

Loading…
Cancel
Save