Browse Source

Show link to registered users if the event is online

pull/20/head
Berkan 6 years ago
parent
commit
409c36c255
  1. 6
      src/EventHub.Application.Contracts/Events/CreateEventDto.cs
  2. 14
      src/EventHub.Application.Contracts/Events/EventLocationDto.cs
  3. 5
      src/EventHub.Application.Contracts/Events/IEventAppService.cs
  4. 2
      src/EventHub.Application/EventHubApplicationAutoMapperProfile.cs
  5. 29
      src/EventHub.Application/Events/EventAppService.cs
  6. 3
      src/EventHub.Domain.Shared/Events/EventConsts.cs
  7. 5
      src/EventHub.Domain.Shared/Localization/EventHub/en.json
  8. 2
      src/EventHub.Domain/Events/Event.cs
  9. 2
      src/EventHub.Domain/Events/EventManager.cs
  10. 2506
      src/EventHub.EntityFrameworkCore.DbMigrations/Migrations/20210208073446_Added_Link_To_Event.Designer.cs
  11. 24
      src/EventHub.EntityFrameworkCore.DbMigrations/Migrations/20210208073446_Added_Link_To_Event.cs
  12. 4
      src/EventHub.EntityFrameworkCore.DbMigrations/Migrations/EventHubMigrationsDbContextModelSnapshot.cs
  13. 1
      src/EventHub.EntityFrameworkCore/EntityFrameworkCore/EventHubDbContextModelCreatingExtensions.cs
  14. 10
      src/EventHub.Web/Controllers/WidgetsController.cs
  15. 28
      src/EventHub.Web/Pages/Events/Components/LocationArea/Default.cshtml
  16. 64
      src/EventHub.Web/Pages/Events/Components/LocationArea/LocationAreaViewComponent.cs
  17. 18
      src/EventHub.Web/Pages/Events/Components/LocationArea/location-area.js
  18. 2
      src/EventHub.Web/Pages/Events/Detail.cshtml
  19. 8
      src/EventHub.Web/Pages/Events/New.cshtml
  20. 5
      src/EventHub.Web/Pages/Events/New.cshtml.cs
  21. 9
      src/EventHub.Web/Pages/Events/New.js

6
src/EventHub.Application.Contracts/Events/CreateEventDto.cs

@ -1,5 +1,6 @@
using System;
using System.ComponentModel.DataAnnotations;
using JetBrains.Annotations;
namespace EventHub.Events
{
@ -23,6 +24,11 @@ namespace EventHub.Events
public string Description { get; set; }
public bool IsOnline { get; set; }
[CanBeNull]
[StringLength(EventConsts.MaxLinkLength, MinimumLength = EventConsts.MinLinkLength)]
public string Link { get; set; }
[Range(0, int.MaxValue)]
public int? Capacity { get; set; }
}}

14
src/EventHub.Application.Contracts/Events/EventLocationDto.cs

@ -0,0 +1,14 @@
using System;
using Volo.Abp.Application.Dtos;
namespace EventHub.Events
{
public class EventLocationDto : EntityDto<Guid>
{
public bool IsOnline { get; set; }
public string Link { get; set; }
public bool IsRegistered { get; set; }
}
}

5
src/EventHub.Application.Contracts/Events/IEventAppService.cs

@ -1,4 +1,5 @@
using System.Threading.Tasks;
using System;
using System.Threading.Tasks;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Application.Services;
@ -11,5 +12,7 @@ namespace EventHub.Events
Task<PagedResultDto<EventInListDto>> GetListAsync(EventListFilterDto input);
Task<EventDetailDto> GetByUrlCodeAsync(string urlCode);
Task<EventLocationDto> GetLocationAsync(Guid id);
}
}

2
src/EventHub.Application/EventHubApplicationAutoMapperProfile.cs

@ -27,6 +27,8 @@ namespace EventHub
.Ignore(x => x.OrganizationDisplayName);
CreateMap<AppUser, EventAttendeeDto>();
CreateMap<Event, EventLocationDto>();
}
}
}

29
src/EventHub.Application/Events/EventAppService.cs

@ -1,7 +1,9 @@
using System;
using System.Linq;
using System.Threading.Tasks;
using EventHub.Events.Registrations;
using EventHub.Organizations;
using EventHub.Users;
using Microsoft.AspNetCore.Authorization;
using Volo.Abp;
using Volo.Abp.Application.Dtos;
@ -13,17 +15,23 @@ namespace EventHub.Events
public class EventAppService : EventHubAppService, IEventAppService
{
private readonly EventManager _eventManager;
private readonly EventRegistrationManager _eventRegistrationManager;
private readonly IRepository<Event, Guid> _eventRepository;
private readonly IRepository<Organization, Guid> _organizationRepository;
private readonly IRepository<AppUser, Guid> _userRepository;
public EventAppService(
EventManager eventManager,
EventRegistrationManager eventRegistrationManager,
IRepository<Event, Guid> eventRepository,
IRepository<Organization, Guid> organizationRepository)
IRepository<Organization, Guid> organizationRepository,
IRepository<AppUser, Guid> userRepository)
{
_eventManager = eventManager;
_eventRegistrationManager = eventRegistrationManager;
_eventRepository = eventRepository;
_organizationRepository = organizationRepository;
_userRepository = userRepository;
}
[Authorize]
@ -46,6 +54,7 @@ namespace EventHub.Events
);
@event.IsOnline = input.IsOnline;
@event.Link = input.Link;
@event.Capacity = input.Capacity;
await _eventRepository.InsertAsync(@event);
@ -119,5 +128,23 @@ namespace EventHub.Events
return dto;
}
[Authorize]
public async Task<EventLocationDto> GetLocationAsync(Guid id)
{
var @event = await _eventRepository.GetAsync(id);
var user = await _userRepository.GetAsync(CurrentUser.GetId());
var dto = ObjectMapper.Map<Event, EventLocationDto>(@event);
dto.IsRegistered = await _eventRegistrationManager.IsRegisteredAsync(@event, user);
if (!dto.IsRegistered)
{
dto.Link = null;
}
return dto;
}
}
}

3
src/EventHub.Domain.Shared/Events/EventConsts.cs

@ -11,5 +11,8 @@
public const int MinDescriptionLength = 50;
public const int MaxDescriptionLength = 2000;
public const int MinLinkLength = 4;
public const int MaxLinkLength = 2000;
}
}

5
src/EventHub.Domain.Shared/Localization/EventHub/en.json

@ -48,6 +48,9 @@
"PersonalWebsite": "Personal Website",
"SocialMedia": "Social Media",
"EventHub:NotAuthorizedToUpdateOrganizationProfile": "You are not authorized to update the \"{OrganizationName}\" organization.",
"EventHub:CapacityOfEventFull": "\"{EventTitle}\" event capacity is full!"
"EventHub:CapacityOfEventFull": "\"{EventTitle}\" event capacity is full!",
"GoToEventAddress": "Go to Event Address",
"AttendeesCanSeeEventLocation": "Only attendees can see the event's {0}.",
"LoginToSeeLocation": "Login to see location"
}
}

2
src/EventHub.Domain/Events/Event.cs

@ -28,6 +28,8 @@ namespace EventHub.Events
public bool IsEmailSentToMembers { get; set; }
public string Link { get; set; }
private Event()
{

2
src/EventHub.Domain/Events/EventManager.cs

@ -21,8 +21,6 @@ namespace EventHub.Events
DateTime endTime,
string description)
{
//TODO: Check capacity and throw business exception!
return new Event(
GuidGenerator.Create(),
organization.Id,

2506
src/EventHub.EntityFrameworkCore.DbMigrations/Migrations/20210208073446_Added_Link_To_Event.Designer.cs

File diff suppressed because it is too large

24
src/EventHub.EntityFrameworkCore.DbMigrations/Migrations/20210208073446_Added_Link_To_Event.cs

@ -0,0 +1,24 @@
using Microsoft.EntityFrameworkCore.Migrations;
namespace EventHub.Migrations
{
public partial class Added_Link_To_Event : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "Link",
table: "AppEvents",
type: "nvarchar(2000)",
maxLength: 2000,
nullable: true);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "Link",
table: "AppEvents");
}
}
}

4
src/EventHub.EntityFrameworkCore.DbMigrations/Migrations/EventHubMigrationsDbContextModelSnapshot.cs

@ -87,6 +87,10 @@ namespace EventHub.Migrations
.HasColumnType("uniqueidentifier")
.HasColumnName("LastModifierId");
b.Property<string>("Link")
.HasMaxLength(2000)
.HasColumnType("nvarchar(2000)");
b.Property<Guid>("OrganizationId")
.HasColumnType("uniqueidentifier");

1
src/EventHub.EntityFrameworkCore/EntityFrameworkCore/EventHubDbContextModelCreatingExtensions.cs

@ -64,6 +64,7 @@ namespace EventHub.EntityFrameworkCore
b.Property(x => x.Description).IsRequired().HasMaxLength(EventConsts.MaxDescriptionLength);
b.Property(x => x.UrlCode).IsRequired().HasMaxLength(EventConsts.UrlCodeLength);
b.Property(x => x.Url).IsRequired().HasMaxLength(EventConsts.MaxUrlLength);
b.Property(x => x.Link).HasMaxLength(EventConsts.MaxLinkLength);
b.HasOne<Organization>().WithMany().HasForeignKey(x => x.OrganizationId).IsRequired().OnDelete(DeleteBehavior.NoAction);

10
src/EventHub.Web/Controllers/WidgetsController.cs

@ -1,5 +1,6 @@
using System;
using EventHub.Web.Pages.Events.Components.AttendeesArea;
using EventHub.Web.Pages.Events.Components.LocationArea;
using EventHub.Web.Pages.Organizations.Components.MembersArea;
using Microsoft.AspNetCore.Mvc;
using Volo.Abp.AspNetCore.Mvc;
@ -25,5 +26,14 @@ namespace EventHub.Web.Controllers
new {organizationId}
);
}
[HttpGet]
public IActionResult EventLocationArea(Guid eventId)
{
return ViewComponent(
typeof(LocationAreaViewComponent),
new {eventId}
);
}
}
}

28
src/EventHub.Web/Pages/Events/Components/LocationArea/Default.cshtml

@ -0,0 +1,28 @@
@using EventHub.Localization
@using Microsoft.AspNetCore.Mvc.Localization
@inject IHtmlLocalizer<EventHubResource> L
@model EventHub.Web.Pages.Events.Components.LocationArea.LocationAreaViewComponent.LocationAreaViewComponentModel
<abp-card class="mb-3" data-event-id="@Model.EventId">
<abp-card-body>
<abp-card-title>@L["Location"] <i class="fas fa-map-marker-alt"></i></abp-card-title>
@if (Model.IsRegistered)
{
if (Model.IsOnline && Model.Link != null)
{
<a href="@Model.Link">@L["GoToEventAddress"]</a>
}
}
else
{
if (Model.IsOnline)
{
<p>@L["AttendeesCanSeeEventLocation", "URL"]</p>
}
else
{
<p>@L["AttendeesCanSeeEventLocation", "location"]</p>
}
}
</abp-card-body>
</abp-card>

64
src/EventHub.Web/Pages/Events/Components/LocationArea/LocationAreaViewComponent.cs

@ -0,0 +1,64 @@
using System;
using System.Threading.Tasks;
using EventHub.Events;
using EventHub.Events.Registrations;
using Microsoft.AspNetCore.Mvc;
using Volo.Abp.AspNetCore.Mvc;
using Volo.Abp.AspNetCore.Mvc.UI.Widgets;
using Volo.Abp.Users;
namespace EventHub.Web.Pages.Events.Components.LocationArea
{
[Widget(
AutoInitialize = true,
RefreshUrl = "/Widgets/EventLocationArea",
ScriptFiles = new[] {"/Pages/Events/Components/LocationArea/location-area.js"}
)]
public class LocationAreaViewComponent : AbpViewComponent
{
private readonly IEventAppService _eventAppService;
private readonly IEventRegistrationAppService _eventRegistrationAppService;
private readonly ICurrentUser _currentUser;
public LocationAreaViewComponent(
IEventAppService eventAppService,
IEventRegistrationAppService eventRegistrationAppService,
ICurrentUser currentUser)
{
_eventAppService = eventAppService;
_eventRegistrationAppService = eventRegistrationAppService;
_currentUser = currentUser;
}
public async Task<IViewComponentResult> InvokeAsync(Guid eventId)
{
var isLoggedIn = _currentUser.IsAuthenticated;
var model = new LocationAreaViewComponentModel
{
EventId = eventId,
IsLoggedIn = isLoggedIn,
};
if (isLoggedIn)
{
var @event = await _eventAppService.GetLocationAsync(eventId);
model.IsOnline = @event.IsOnline;
model.IsRegistered = @event.IsRegistered;
model.Link = @event.Link;
}
return View("~/Pages/Events/Components/LocationArea/Default.cshtml", model);
}
public class LocationAreaViewComponentModel
{
public Guid EventId { get; set; }
public bool IsLoggedIn { get; set; }
public bool IsRegistered { get; set; }
public bool IsOnline { get; set; }
public string Link { get; set; }
}
}
}

18
src/EventHub.Web/Pages/Events/Components/LocationArea/location-area.js

@ -0,0 +1,18 @@
(function () {
abp.widgets.LocationArea = function ($wrapper) {
var eventId = $wrapper.find('[data-event-id]').attr('data-event-id');
return {
getFilters: function () {
return {
eventId: eventId
};
}
};
};
abp.event.on("EventHub.Event.RegistrationStatusChanged", function(){
$('[data-widget-name="LocationArea"]')
.data('abp-widget-manager')
.refresh();
});
})();

2
src/EventHub.Web/Pages/Events/Detail.cshtml

@ -3,6 +3,7 @@
@using EventHub.Localization
@using EventHub.Web.Pages.Events
@using EventHub.Web.Pages.Events.Components.AttendeesArea
@using EventHub.Web.Pages.Events.Components.LocationArea
@using EventHub.Web.Pages.Events.Components.RegistrationArea
@using Microsoft.AspNetCore.Mvc.Localization
@model EventHub.Web.Pages.Events.DetailPageModel
@ -27,5 +28,6 @@
<abp-column size-lg="_4" size-md="_6">
@await Component.InvokeAsync(typeof(RegistrationAreaViewComponent), new {eventId = Model.Event.Id})
@await Component.InvokeAsync(typeof(AttendeesAreaViewComponent), new {eventId = Model.Event.Id})
@await Component.InvokeAsync(typeof(LocationAreaViewComponent), new {eventId = Model.Event.Id})
</abp-column>
</abp-row>

8
src/EventHub.Web/Pages/Events/New.cshtml

@ -3,6 +3,11 @@
@using EventHub.Localization
@using Microsoft.AspNetCore.Mvc.Localization
@model EventHub.Web.Pages.Events.NewPageModel
@section scripts {
<abp-script src="/Pages/Events/New.js"/>
}
<h1>@L["NewEvent"]</h1>
@if (!Model.Organizations.Any())
{
@ -20,6 +25,9 @@ else
<abp-input asp-for="Event.EndTime" />
<abp-input asp-for="Event.Description" />
<abp-input asp-for="Event.IsOnline" />
<div id="event-link-form" style="display: none">
<abp-input asp-for="Event.Link" />
</div>
<abp-input asp-for="Event.Capacity" />
<abp-button size="Large" button-type="Primary" type="submit" text="@L["Submit"].Value" />
</form>

5
src/EventHub.Web/Pages/Events/New.cshtml.cs

@ -6,6 +6,7 @@ using System.Linq;
using System.Threading.Tasks;
using EventHub.Events;
using EventHub.Organizations;
using JetBrains.Annotations;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Rendering;
using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Form;
@ -94,6 +95,10 @@ namespace EventHub.Web.Pages.Events
public string Description { get; set; }
public bool IsOnline { get; set; }
[CanBeNull]
[StringLength(EventConsts.MaxLinkLength, MinimumLength = EventConsts.MinLinkLength)]
public string Link { get; set; }
public int? Capacity { get; set; }
}

9
src/EventHub.Web/Pages/Events/New.js

@ -0,0 +1,9 @@
$(function () {
$('#Event_IsOnline').click(function() {
if ($(this).is(':checked')) {
$("#event-link-form").show();
}else{
$("#event-link-form").hide();
}
});
});
Loading…
Cancel
Save