Browse Source

Merge pull request #20 from volosoft/berkan/location-language-capacity

Add Event location, language, and capacity features
pull/21/head
Halil İbrahim Kalkan 6 years ago
committed by GitHub
parent
commit
562ee80037
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 10
      src/EventHub.Application.Contracts/Events/CountryLookupDto.cs
  2. 16
      src/EventHub.Application.Contracts/Events/CreateEventDto.cs
  3. 2
      src/EventHub.Application.Contracts/Events/EventDetailDto.cs
  4. 2
      src/EventHub.Application.Contracts/Events/EventDto.cs
  5. 19
      src/EventHub.Application.Contracts/Events/EventLocationDto.cs
  6. 8
      src/EventHub.Application.Contracts/Events/IEventAppService.cs
  7. 6
      src/EventHub.Application/EventHubApplicationAutoMapperProfile.cs
  8. 56
      src/EventHub.Application/Events/EventAppService.cs
  9. 7
      src/EventHub.Domain.Shared/Countries/CountryConsts.cs
  10. 1
      src/EventHub.Domain.Shared/EventHubErrorCodes.cs
  11. 9
      src/EventHub.Domain.Shared/Events/EventConsts.cs
  12. 8
      src/EventHub.Domain.Shared/Localization/EventHub/en.json
  13. 24
      src/EventHub.Domain/Countries/Country.cs
  14. 218
      src/EventHub.Domain/EventHubDataSeedContributor.cs
  15. 33
      src/EventHub.Domain/Events/Event.cs
  16. 2
      src/EventHub.Domain/Events/EventManager.cs
  17. 8
      src/EventHub.Domain/Events/Registrations/EventRegistrationManager.cs
  18. 2506
      src/EventHub.EntityFrameworkCore.DbMigrations/Migrations/20210208073446_Added_Link_To_Event.Designer.cs
  19. 24
      src/EventHub.EntityFrameworkCore.DbMigrations/Migrations/20210208073446_Added_Link_To_Event.cs
  20. 2534
      src/EventHub.EntityFrameworkCore.DbMigrations/Migrations/20210208140845_Added_Countries.Designer.cs
  21. 64
      src/EventHub.EntityFrameworkCore.DbMigrations/Migrations/20210208140845_Added_Countries.cs
  22. 2538
      src/EventHub.EntityFrameworkCore.DbMigrations/Migrations/20210208141144_Added_City_To_Event.Designer.cs
  23. 24
      src/EventHub.EntityFrameworkCore.DbMigrations/Migrations/20210208141144_Added_City_To_Event.cs
  24. 2542
      src/EventHub.EntityFrameworkCore.DbMigrations/Migrations/20210209072715_Added_Language_To_Event.Designer.cs
  25. 24
      src/EventHub.EntityFrameworkCore.DbMigrations/Migrations/20210209072715_Added_Language_To_Event.cs
  26. 2542
      src/EventHub.EntityFrameworkCore.DbMigrations/Migrations/20210209081448_Renamed_Link_To_OnlineLink.Designer.cs
  27. 23
      src/EventHub.EntityFrameworkCore.DbMigrations/Migrations/20210209081448_Renamed_Link_To_OnlineLink.cs
  28. 40
      src/EventHub.EntityFrameworkCore.DbMigrations/Migrations/EventHubMigrationsDbContextModelSnapshot.cs
  29. 6
      src/EventHub.EntityFrameworkCore/EntityFrameworkCore/EventHubDbContext.cs
  30. 19
      src/EventHub.EntityFrameworkCore/EntityFrameworkCore/EventHubDbContextModelCreatingExtensions.cs
  31. 10
      src/EventHub.Web/Controllers/WidgetsController.cs
  32. 45
      src/EventHub.Web/Pages/Events/Components/LocationArea/Default.cshtml
  33. 67
      src/EventHub.Web/Pages/Events/Components/LocationArea/LocationAreaViewComponent.cs
  34. 18
      src/EventHub.Web/Pages/Events/Components/LocationArea/location-area.js
  35. 7
      src/EventHub.Web/Pages/Events/Detail.cshtml
  36. 13
      src/EventHub.Web/Pages/Events/New.cshtml
  37. 57
      src/EventHub.Web/Pages/Events/New.cshtml.cs
  38. 14
      src/EventHub.Web/Pages/Events/New.js
  39. 47
      test/EventHub.Application.Tests/Events/EventAppServiceTests.cs
  40. 43
      test/EventHub.Application.Tests/Events/Registrations/EventRegistrationAppServiceTests.cs
  41. 20
      test/EventHub.Domain.Tests/Events/EventTests.cs
  42. 3
      test/EventHub.TestBase/EventHubTestDataSeedContributor.cs

10
src/EventHub.Application.Contracts/Events/CountryLookupDto.cs

@ -0,0 +1,10 @@
using System;
using Volo.Abp.Application.Dtos;
namespace EventHub.Events
{
public class CountryLookupDto : EntityDto<Guid>
{
public string Name { get; set; }
}
}

16
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,21 @@ namespace EventHub.Events
public string Description { get; set; }
public bool IsOnline { get; set; }
[CanBeNull]
[StringLength(EventConsts.MaxOnlineLinkLength, MinimumLength = EventConsts.MinOnlineLinkLength)]
public string OnlineLink { get; set; }
public Guid? CountryId { get; set; }
[CanBeNull]
[StringLength(EventConsts.MaxCityLength, MinimumLength = EventConsts.MinCityLength)]
public string City { get; set; }
[CanBeNull]
[StringLength(EventConsts.MaxLanguageLength, MinimumLength = EventConsts.MinLanguageLength)]
public string Language { get; set; }
[Range(1, int.MaxValue)]
public int? Capacity { get; set; }
}}

2
src/EventHub.Application.Contracts/Events/EventDetailDto.cs

@ -25,6 +25,8 @@ namespace EventHub.Events
public string Url { get; set; }
public string Language { get; set; }
public int? Capacity { get; set; }
}
}

2
src/EventHub.Application.Contracts/Events/EventDto.cs

@ -21,6 +21,8 @@ namespace EventHub.Events
public bool IsOnline { get; set; }
public string Language { get; set; }
public int? Capacity { get; set; }
}
}

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

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

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

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

6
src/EventHub.Application/EventHubApplicationAutoMapperProfile.cs

@ -1,4 +1,5 @@
using AutoMapper;
using EventHub.Countries;
using EventHub.Events;
using EventHub.Events.Registrations;
using EventHub.Organizations;
@ -27,6 +28,11 @@ namespace EventHub
.Ignore(x => x.OrganizationDisplayName);
CreateMap<AppUser, EventAttendeeDto>();
CreateMap<Event, EventLocationDto>()
.Ignore(x => x.Country);
CreateMap<Country, CountryLookupDto>();
}
}
}

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

@ -1,7 +1,11 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using EventHub.Countries;
using EventHub.Events.Registrations;
using EventHub.Organizations;
using EventHub.Users;
using Microsoft.AspNetCore.Authorization;
using Volo.Abp;
using Volo.Abp.Application.Dtos;
@ -13,17 +17,26 @@ 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;
private readonly IRepository<Country, Guid> _countriesRepository;
public EventAppService(
EventManager eventManager,
EventRegistrationManager eventRegistrationManager,
IRepository<Event, Guid> eventRepository,
IRepository<Organization, Guid> organizationRepository)
IRepository<Organization, Guid> organizationRepository,
IRepository<AppUser, Guid> userRepository,
IRepository<Country, Guid> countriesRepository)
{
_eventManager = eventManager;
_eventRegistrationManager = eventRegistrationManager;
_eventRepository = eventRepository;
_organizationRepository = organizationRepository;
_userRepository = userRepository;
_countriesRepository = countriesRepository;
}
[Authorize]
@ -45,7 +58,8 @@ namespace EventHub.Events
input.Description
);
@event.IsOnline = input.IsOnline;
@event.SetLocation(input.IsOnline, input.OnlineLink, input.CountryId, input.City);
@event.Language = input.Language;
@event.Capacity = input.Capacity;
await _eventRepository.InsertAsync(@event);
@ -119,5 +133,43 @@ 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.OnlineLink = null;
dto.City = null;
}
if (dto.IsRegistered && @event.CountryId.HasValue)
{
dto.Country = (await _countriesRepository.GetAsync(@event.CountryId.Value)).Name;
}
return dto;
}
[Authorize]
public async Task<List<CountryLookupDto>> GetCountriesLookupAsync()
{
var countriesQueryable = await _countriesRepository.GetQueryableAsync();
var query = from country in countriesQueryable
orderby country.Name ascending
select country;
var countries = await AsyncExecuter.ToListAsync(query);
return ObjectMapper.Map<List<Country>, List<CountryLookupDto>>(countries);
}
}
}

7
src/EventHub.Domain.Shared/Countries/CountryConsts.cs

@ -0,0 +1,7 @@
namespace EventHub.Countries
{
public static class CountryConsts
{
public const int MaxNameLength = 32;
}
}

1
src/EventHub.Domain.Shared/EventHubErrorCodes.cs

@ -7,5 +7,6 @@
public const string EventEndTimeCantBeEarlierThanStartTime = "EventHub:EventEndTimeCantBeEarlierThanStartTime";
public const string CantRegisterOrUnregisterForAPastEvent = "EventHub:CantRegisterOrUnregisterForAPastEvent";
public const string NotAuthorizedToUpdateOrganizationProfile = "EventHub:NotAuthorizedToUpdateOrganizationProfile";
public const string CapacityOfEventFull = "EventHub:CapacityOfEventFull";
}
}

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

@ -11,5 +11,14 @@
public const int MinDescriptionLength = 50;
public const int MaxDescriptionLength = 2000;
public const int MinOnlineLinkLength = 4;
public const int MaxOnlineLinkLength = 2000;
public const int MinCityLength = 2;
public const int MaxCityLength = 32;
public const int MinLanguageLength = 2;
public const int MaxLanguageLength = 16;
}
}

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

@ -47,6 +47,12 @@
"EditOrganization": "Edit Organization",
"PersonalWebsite": "Personal Website",
"SocialMedia": "Social Media",
"EventHub:NotAuthorizedToUpdateOrganizationProfile": "You are not authorized to update the \"{OrganizationName}\" organization."
"EventHub:NotAuthorizedToUpdateOrganizationProfile": "You are not authorized to update the \"{OrganizationName}\" organization.",
"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",
"LocationHasNotSpecifiedYet": "Event {0} has not been specified yet.",
"Language": "Language"
}
}

24
src/EventHub.Domain/Countries/Country.cs

@ -0,0 +1,24 @@
using System;
using Volo.Abp;
using Volo.Abp.Domain.Entities;
namespace EventHub.Countries
{
public class Country : Entity<Guid>
{
public string Name { get; private set; }
private Country()
{
}
internal Country(
Guid id,
string name)
: base(id)
{
Name = Check.NotNullOrWhiteSpace(name, nameof(name), CountryConsts.MaxNameLength);
}
}
}

218
src/EventHub.Domain/EventHubDataSeedContributor.cs

@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using EventHub.Countries;
using EventHub.Events;
using EventHub.Events.Registrations;
using EventHub.Organizations;
@ -23,6 +24,7 @@ namespace EventHub
private readonly EventManager _eventManager;
private readonly EventRegistrationManager _eventRegistrationManager;
private readonly IRepository<AppUser, Guid> _userRepository;
private readonly IRepository<Country, Guid> _countryRepository;
public EventHubDataSeedContributor(
IGuidGenerator guidGenerator,
@ -32,8 +34,8 @@ namespace EventHub
IRepository<Event, Guid> eventRepository,
EventManager eventManager,
EventRegistrationManager eventRegistrationManager,
IRepository<AppUser, Guid> userRepository
)
IRepository<AppUser, Guid> userRepository,
IRepository<Country, Guid> countryRepository)
{
_guidGenerator = guidGenerator;
_identityUserManager = identityUserManager;
@ -43,6 +45,7 @@ namespace EventHub
_eventManager = eventManager;
_eventRegistrationManager = eventRegistrationManager;
_userRepository = userRepository;
_countryRepository = countryRepository;
}
public async Task SeedAsync(DataSeedContext context)
@ -52,6 +55,7 @@ namespace EventHub
await SeedOrganizationsAsync();
await SeedEventsAsync();
#endif
await SeedCountriesAsync();
}
private async Task SeedUsersAsync()
@ -350,5 +354,215 @@ namespace EventHub
await _eventRegistrationManager.RegisterAsync(upcomingEvent15, userMark);
await _eventRegistrationManager.RegisterAsync(upcomingEvent15, userSandra);
}
private async Task SeedCountriesAsync()
{
if (await _countryRepository.GetCountAsync() > 0)
{
return;
}
var countries = new List<Country>
{
new Country(Guid.NewGuid(), "Afghanistan"),
new Country(Guid.NewGuid(), "Albania"),
new Country(Guid.NewGuid(), "Algeria"),
new Country(Guid.NewGuid(), "Andorra"),
new Country(Guid.NewGuid(), "Angola"),
new Country(Guid.NewGuid(), "Antigua and Barbuda"),
new Country(Guid.NewGuid(), "Argentina"),
new Country(Guid.NewGuid(), "Armenia"),
new Country(Guid.NewGuid(), "Australia"),
new Country(Guid.NewGuid(), "Austria"),
new Country(Guid.NewGuid(), "Azerbaijan"),
new Country(Guid.NewGuid(), "Bahamas"),
new Country(Guid.NewGuid(), "Bahrain"),
new Country(Guid.NewGuid(), "Bangladesh"),
new Country(Guid.NewGuid(), "Barbados"),
new Country(Guid.NewGuid(), "Belarus"),
new Country(Guid.NewGuid(), "Belgium"),
new Country(Guid.NewGuid(), "Belize"),
new Country(Guid.NewGuid(), "Benin"),
new Country(Guid.NewGuid(), "Bhutan"),
new Country(Guid.NewGuid(), "Bolivia"),
new Country(Guid.NewGuid(), "Bosnia and Herzegovina"),
new Country(Guid.NewGuid(), "Botswana"),
new Country(Guid.NewGuid(), "Brazil"),
new Country(Guid.NewGuid(), "Brunei"),
new Country(Guid.NewGuid(), "Bulgaria"),
new Country(Guid.NewGuid(), "Burkina Faso"),
new Country(Guid.NewGuid(), "Burundi"),
new Country(Guid.NewGuid(), "Côte d'Ivoire"),
new Country(Guid.NewGuid(), "Cabo Verde"),
new Country(Guid.NewGuid(), "Cambodia"),
new Country(Guid.NewGuid(), "Cameroon"),
new Country(Guid.NewGuid(), "Canada"),
new Country(Guid.NewGuid(), "Central African Republic"),
new Country(Guid.NewGuid(), "Chad"),
new Country(Guid.NewGuid(), "Chile"),
new Country(Guid.NewGuid(), "China"),
new Country(Guid.NewGuid(), "Colombia"),
new Country(Guid.NewGuid(), "Comoros"),
new Country(Guid.NewGuid(), "Congo (Congo-Brazzaville)"),
new Country(Guid.NewGuid(), "Costa Rica"),
new Country(Guid.NewGuid(), "Croatia"),
new Country(Guid.NewGuid(), "Cuba"),
new Country(Guid.NewGuid(), "Cyprus"),
new Country(Guid.NewGuid(), "Czechia (Czech Republic)"),
new Country(Guid.NewGuid(), "Democratic Republic of the Congo"),
new Country(Guid.NewGuid(), "Denmark"),
new Country(Guid.NewGuid(), "Djibouti"),
new Country(Guid.NewGuid(), "Dominica"),
new Country(Guid.NewGuid(), "Dominican Republic"),
new Country(Guid.NewGuid(), "Ecuador"),
new Country(Guid.NewGuid(), "Egypt"),
new Country(Guid.NewGuid(), "El Salvador"),
new Country(Guid.NewGuid(), "Equatorial Guinea"),
new Country(Guid.NewGuid(), "Eritrea"),
new Country(Guid.NewGuid(), "Estonia"),
new Country(Guid.NewGuid(), "Eswatini (formerly Swaziland)"),
new Country(Guid.NewGuid(), "Ethiopia"),
new Country(Guid.NewGuid(), "Fiji"),
new Country(Guid.NewGuid(), "Finland"),
new Country(Guid.NewGuid(), "France"),
new Country(Guid.NewGuid(), "Gabon"),
new Country(Guid.NewGuid(), "Gambia"),
new Country(Guid.NewGuid(), "Georgia"),
new Country(Guid.NewGuid(), "Germany"),
new Country(Guid.NewGuid(), "Ghana"),
new Country(Guid.NewGuid(), "Greece"),
new Country(Guid.NewGuid(), "Grenada"),
new Country(Guid.NewGuid(), "Guatemala"),
new Country(Guid.NewGuid(), "Guinea"),
new Country(Guid.NewGuid(), "Guinea-Bissau"),
new Country(Guid.NewGuid(), "Guyana"),
new Country(Guid.NewGuid(), "Haiti"),
new Country(Guid.NewGuid(), "Holy See"),
new Country(Guid.NewGuid(), "Honduras"),
new Country(Guid.NewGuid(), "Hungary"),
new Country(Guid.NewGuid(), "Iceland"),
new Country(Guid.NewGuid(), "India"),
new Country(Guid.NewGuid(), "Indonesia"),
new Country(Guid.NewGuid(), "Iran"),
new Country(Guid.NewGuid(), "Iraq"),
new Country(Guid.NewGuid(), "Ireland"),
new Country(Guid.NewGuid(), "Israel"),
new Country(Guid.NewGuid(), "Italy"),
new Country(Guid.NewGuid(), "Jamaica"),
new Country(Guid.NewGuid(), "Japan"),
new Country(Guid.NewGuid(), "Jordan"),
new Country(Guid.NewGuid(), "Kazakhstan"),
new Country(Guid.NewGuid(), "Kenya"),
new Country(Guid.NewGuid(), "Kiribati"),
new Country(Guid.NewGuid(), "Kuwait"),
new Country(Guid.NewGuid(), "Kyrgyzstan"),
new Country(Guid.NewGuid(), "Laos"),
new Country(Guid.NewGuid(), "Latvia"),
new Country(Guid.NewGuid(), "Lebanon"),
new Country(Guid.NewGuid(), "Lesotho"),
new Country(Guid.NewGuid(), "Liberia"),
new Country(Guid.NewGuid(), "Libya"),
new Country(Guid.NewGuid(), "Liechtenstein"),
new Country(Guid.NewGuid(), "Lithuania"),
new Country(Guid.NewGuid(), "Luxembourg"),
new Country(Guid.NewGuid(), "Madagascar"),
new Country(Guid.NewGuid(), "Malawi"),
new Country(Guid.NewGuid(), "Malaysia"),
new Country(Guid.NewGuid(), "Maldives"),
new Country(Guid.NewGuid(), "Mali"),
new Country(Guid.NewGuid(), "Malta"),
new Country(Guid.NewGuid(), "Marshall Islands"),
new Country(Guid.NewGuid(), "Mauritania"),
new Country(Guid.NewGuid(), "Mauritius"),
new Country(Guid.NewGuid(), "Mexico"),
new Country(Guid.NewGuid(), "Micronesia"),
new Country(Guid.NewGuid(), "Moldova"),
new Country(Guid.NewGuid(), "Monaco"),
new Country(Guid.NewGuid(), "Mongolia"),
new Country(Guid.NewGuid(), "Montenegro"),
new Country(Guid.NewGuid(), "Morocco"),
new Country(Guid.NewGuid(), "Mozambique"),
new Country(Guid.NewGuid(), "Myanmar (formerly Burma)"),
new Country(Guid.NewGuid(), "Namibia"),
new Country(Guid.NewGuid(), "Nauru"),
new Country(Guid.NewGuid(), "Nepal"),
new Country(Guid.NewGuid(), "Netherlands"),
new Country(Guid.NewGuid(), "New Zealand"),
new Country(Guid.NewGuid(), "Nicaragua"),
new Country(Guid.NewGuid(), "Niger"),
new Country(Guid.NewGuid(), "Nigeria"),
new Country(Guid.NewGuid(), "North Korea"),
new Country(Guid.NewGuid(), "North Macedonia"),
new Country(Guid.NewGuid(), "Norway"),
new Country(Guid.NewGuid(), "Oman"),
new Country(Guid.NewGuid(), "Pakistan"),
new Country(Guid.NewGuid(), "Palau"),
new Country(Guid.NewGuid(), "Palestine State"),
new Country(Guid.NewGuid(), "Panama"),
new Country(Guid.NewGuid(), "Papua New Guinea"),
new Country(Guid.NewGuid(), "Paraguay"),
new Country(Guid.NewGuid(), "Peru"),
new Country(Guid.NewGuid(), "Philippines"),
new Country(Guid.NewGuid(), "Poland"),
new Country(Guid.NewGuid(), "Portugal"),
new Country(Guid.NewGuid(), "Qatar"),
new Country(Guid.NewGuid(), "Romania"),
new Country(Guid.NewGuid(), "Russia"),
new Country(Guid.NewGuid(), "Rwanda"),
new Country(Guid.NewGuid(), "Saint Kitts and Nevis"),
new Country(Guid.NewGuid(), "Saint Lucia"),
new Country(Guid.NewGuid(), "Saint Vincent and the Grenadines"),
new Country(Guid.NewGuid(), "Samoa"),
new Country(Guid.NewGuid(), "San Marino"),
new Country(Guid.NewGuid(), "Sao Tome and Principe"),
new Country(Guid.NewGuid(), "Saudi Arabia"),
new Country(Guid.NewGuid(), "Senegal"),
new Country(Guid.NewGuid(), "Serbia"),
new Country(Guid.NewGuid(), "Seychelles"),
new Country(Guid.NewGuid(), "Sierra Leone"),
new Country(Guid.NewGuid(), "Singapore"),
new Country(Guid.NewGuid(), "Slovakia"),
new Country(Guid.NewGuid(), "Slovenia"),
new Country(Guid.NewGuid(), "Solomon Islands"),
new Country(Guid.NewGuid(), "Somalia"),
new Country(Guid.NewGuid(), "South Africa"),
new Country(Guid.NewGuid(), "South Korea"),
new Country(Guid.NewGuid(), "South Sudan"),
new Country(Guid.NewGuid(), "Spain"),
new Country(Guid.NewGuid(), "Sri Lanka"),
new Country(Guid.NewGuid(), "Sudan"),
new Country(Guid.NewGuid(), "Suriname"),
new Country(Guid.NewGuid(), "Sweden"),
new Country(Guid.NewGuid(), "Switzerland"),
new Country(Guid.NewGuid(), "Syria"),
new Country(Guid.NewGuid(), "Tajikistan"),
new Country(Guid.NewGuid(), "Tanzania"),
new Country(Guid.NewGuid(), "Thailand"),
new Country(Guid.NewGuid(), "Timor-Leste"),
new Country(Guid.NewGuid(), "Togo"),
new Country(Guid.NewGuid(), "Tonga"),
new Country(Guid.NewGuid(), "Trinidad and Tobago"),
new Country(Guid.NewGuid(), "Tunisia"),
new Country(Guid.NewGuid(), "Turkey"),
new Country(Guid.NewGuid(), "Turkmenistan"),
new Country(Guid.NewGuid(), "Tuvalu"),
new Country(Guid.NewGuid(), "Uganda"),
new Country(Guid.NewGuid(), "Ukraine"),
new Country(Guid.NewGuid(), "United Arab Emirates"),
new Country(Guid.NewGuid(), "United Kingdom"),
new Country(Guid.NewGuid(), "United States of America"),
new Country(Guid.NewGuid(), "Uruguay"),
new Country(Guid.NewGuid(), "Uzbekistan"),
new Country(Guid.NewGuid(), "Vanuatu"),
new Country(Guid.NewGuid(), "Venezuela"),
new Country(Guid.NewGuid(), "Vietnam"),
new Country(Guid.NewGuid(), "Yemen"),
new Country(Guid.NewGuid(), "Zambia"),
new Country(Guid.NewGuid(), "Zimbabwe")
};
await _countryRepository.InsertManyAsync(countries);
}
}
}

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

@ -20,7 +20,15 @@ namespace EventHub.Events
public string Description { get; private set; }
public bool IsOnline { get; set; }
public bool IsOnline { get; private set; }
public string OnlineLink { get; private set; }
public Guid? CountryId { get; private set; }
public string City { get; private set; }
public string Language { get; set; }
public int? Capacity { get; set; }
@ -74,5 +82,28 @@ namespace EventHub.Events
EndTime = endTime;
return this;
}
public Event SetLocation(bool isOnline, string onlineLink, Guid? countryId, string city)
{
IsOnline = isOnline;
if (isOnline)
{
if (!onlineLink.IsNullOrWhiteSpace())
{
OnlineLink = onlineLink;
}
return this;
}
if (countryId.HasValue && !city.IsNullOrWhiteSpace())
{
CountryId = countryId;
City = city;
}
return this;
}
}
}

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,

8
src/EventHub.Domain/Events/Registrations/EventRegistrationManager.cs

@ -27,7 +27,15 @@ namespace EventHub.Events.Registrations
{
return;
}
var registrationCount = await _eventRegistrationRepository.CountAsync(x => x.EventId == @event.Id);
if (@event.Capacity != null && registrationCount >= @event.Capacity)
{
throw new BusinessException(EventHubErrorCodes.CapacityOfEventFull)
.WithData("EventTitle", @event.Title);
}
await _eventRegistrationRepository.InsertAsync(
new EventRegistration(
GuidGenerator.Create(),

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");
}
}
}

2534
src/EventHub.EntityFrameworkCore.DbMigrations/Migrations/20210208140845_Added_Countries.Designer.cs

File diff suppressed because it is too large

64
src/EventHub.EntityFrameworkCore.DbMigrations/Migrations/20210208140845_Added_Countries.cs

@ -0,0 +1,64 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
namespace EventHub.Migrations
{
public partial class Added_Countries : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<Guid>(
name: "CountryId",
table: "AppEvents",
type: "uniqueidentifier",
nullable: true);
migrationBuilder.CreateTable(
name: "AppCountries",
columns: table => new
{
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
Name = table.Column<string>(type: "nvarchar(32)", maxLength: 32, nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_AppCountries", x => x.Id);
});
migrationBuilder.CreateIndex(
name: "IX_AppEvents_CountryId",
table: "AppEvents",
column: "CountryId");
migrationBuilder.CreateIndex(
name: "IX_AppCountries_Name",
table: "AppCountries",
column: "Name");
migrationBuilder.AddForeignKey(
name: "FK_AppEvents_AppCountries_CountryId",
table: "AppEvents",
column: "CountryId",
principalTable: "AppCountries",
principalColumn: "Id");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_AppEvents_AppCountries_CountryId",
table: "AppEvents");
migrationBuilder.DropTable(
name: "AppCountries");
migrationBuilder.DropIndex(
name: "IX_AppEvents_CountryId",
table: "AppEvents");
migrationBuilder.DropColumn(
name: "CountryId",
table: "AppEvents");
}
}
}

2538
src/EventHub.EntityFrameworkCore.DbMigrations/Migrations/20210208141144_Added_City_To_Event.Designer.cs

File diff suppressed because it is too large

24
src/EventHub.EntityFrameworkCore.DbMigrations/Migrations/20210208141144_Added_City_To_Event.cs

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

2542
src/EventHub.EntityFrameworkCore.DbMigrations/Migrations/20210209072715_Added_Language_To_Event.Designer.cs

File diff suppressed because it is too large

24
src/EventHub.EntityFrameworkCore.DbMigrations/Migrations/20210209072715_Added_Language_To_Event.cs

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

2542
src/EventHub.EntityFrameworkCore.DbMigrations/Migrations/20210209081448_Renamed_Link_To_OnlineLink.Designer.cs

File diff suppressed because it is too large

23
src/EventHub.EntityFrameworkCore.DbMigrations/Migrations/20210209081448_Renamed_Link_To_OnlineLink.cs

@ -0,0 +1,23 @@
using Microsoft.EntityFrameworkCore.Migrations;
namespace EventHub.Migrations
{
public partial class Renamed_Link_To_OnlineLink : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.RenameColumn(
name: "Link",
table: "AppEvents",
newName: "OnlineLink");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.RenameColumn(
name: "OnlineLink",
table: "AppEvents",
newName: "Link");
}
}
}

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

@ -21,6 +21,24 @@ namespace EventHub.Migrations
.HasAnnotation("Relational:MaxIdentifierLength", 128)
.HasAnnotation("ProductVersion", "5.0.2");
modelBuilder.Entity("EventHub.Countries.Country", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uniqueidentifier");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(32)
.HasColumnType("nvarchar(32)");
b.HasKey("Id");
b.HasIndex("Name");
b.ToTable("AppCountries");
});
modelBuilder.Entity("EventHub.Events.Event", b =>
{
b.Property<Guid>("Id")
@ -30,12 +48,19 @@ namespace EventHub.Migrations
b.Property<int?>("Capacity")
.HasColumnType("int");
b.Property<string>("City")
.HasMaxLength(32)
.HasColumnType("nvarchar(32)");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasMaxLength(40)
.HasColumnType("nvarchar(40)")
.HasColumnName("ConcurrencyStamp");
b.Property<Guid?>("CountryId")
.HasColumnType("uniqueidentifier");
b.Property<DateTime>("CreationTime")
.HasColumnType("datetime2")
.HasColumnName("CreationTime");
@ -79,6 +104,10 @@ namespace EventHub.Migrations
b.Property<bool>("IsRemindingEmailSent")
.HasColumnType("bit");
b.Property<string>("Language")
.HasMaxLength(16)
.HasColumnType("nvarchar(16)");
b.Property<DateTime?>("LastModificationTime")
.HasColumnType("datetime2")
.HasColumnName("LastModificationTime");
@ -87,6 +116,10 @@ namespace EventHub.Migrations
.HasColumnType("uniqueidentifier")
.HasColumnName("LastModifierId");
b.Property<string>("OnlineLink")
.HasMaxLength(2000)
.HasColumnType("nvarchar(2000)");
b.Property<Guid>("OrganizationId")
.HasColumnType("uniqueidentifier");
@ -110,6 +143,8 @@ namespace EventHub.Migrations
b.HasKey("Id");
b.HasIndex("CountryId");
b.HasIndex("StartTime");
b.HasIndex("UrlCode");
@ -2100,6 +2135,11 @@ namespace EventHub.Migrations
modelBuilder.Entity("EventHub.Events.Event", b =>
{
b.HasOne("EventHub.Countries.Country", null)
.WithMany()
.HasForeignKey("CountryId")
.OnDelete(DeleteBehavior.NoAction);
b.HasOne("EventHub.Organizations.Organization", null)
.WithMany()
.HasForeignKey("OrganizationId")

6
src/EventHub.EntityFrameworkCore/EntityFrameworkCore/EventHubDbContext.cs

@ -1,4 +1,5 @@
using EventHub.Events;
using EventHub.Countries;
using EventHub.Events;
using EventHub.Events.Registrations;
using EventHub.Organizations;
using EventHub.Organizations.Memberships;
@ -29,7 +30,8 @@ namespace EventHub.EntityFrameworkCore
public DbSet<OrganizationMembership> OrganizationMemberships { get; set; }
public DbSet<Event> Events { get; set; }
public DbSet<EventRegistration> EventRegistrations { get; set; }
public DbSet<Country> Countries { get; set; }
public EventHubDbContext(DbContextOptions<EventHubDbContext> options)
: base(options)
{

19
src/EventHub.EntityFrameworkCore/EntityFrameworkCore/EventHubDbContextModelCreatingExtensions.cs

@ -1,4 +1,5 @@
using EventHub.Events;
using EventHub.Countries;
using EventHub.Events;
using EventHub.Events.Registrations;
using EventHub.Organizations;
using EventHub.Organizations.Memberships;
@ -64,8 +65,13 @@ 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.OnlineLink).HasMaxLength(EventConsts.MaxOnlineLinkLength);
b.Property(x => x.City).HasMaxLength(EventConsts.MaxCityLength);
b.Property(x => x.Language).HasMaxLength(EventConsts.MaxLanguageLength);
b.HasOne<Organization>().WithMany().HasForeignKey(x => x.OrganizationId).IsRequired().OnDelete(DeleteBehavior.NoAction);
b.HasOne<Country>().WithMany().HasForeignKey(x => x.CountryId).OnDelete(DeleteBehavior.NoAction);
b.HasIndex(x => new {x.OrganizationId, x.StartTime});
b.HasIndex(x => x.StartTime);
@ -87,6 +93,17 @@ namespace EventHub.EntityFrameworkCore
b.HasIndex(x => new {x.EventId, x.UserId});
});
builder.Entity<Country>(b =>
{
b.ToTable(EventHubConsts.DbTablePrefix + "Countries", EventHubConsts.DbSchema);
b.ConfigureByConvention();
b.Property(x => x.Name).IsRequired().HasMaxLength(CountryConsts.MaxNameLength);
b.HasIndex(x => new {x.Name});
});
}
}
}

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}
);
}
}
}

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

@ -0,0 +1,45 @@
@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)
{
if (Model.OnlineLink != null)
{
<a href="@Model.OnlineLink">@L["GoToEventAddress"]</a>
}
else
{
<p>@L["LocationHasNotSpecifiedYet", "URL"]</p>
}
}else
{
if (Model.Country != null && Model.City != null)
{
<p>@Model.Country/@Model.City</p>
}
else
{
<p>@L["LocationHasNotSpecifiedYet", "location"]</p>
}
}
}
else
{
if (Model.IsOnline)
{
<p>@L["AttendeesCanSeeEventLocation", "URL"]</p>
}
else
{
<p>@L["AttendeesCanSeeEventLocation", "location"]</p>
}
}
</abp-card-body>
</abp-card>

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

@ -0,0 +1,67 @@
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,
IsRegistered = false
};
if (isLoggedIn)
{
var @event = await _eventAppService.GetLocationAsync(eventId);
model.IsOnline = @event.IsOnline;
model.IsRegistered = @event.IsRegistered;
model.OnlineLink = @event.OnlineLink;
model.Country = @event.Country;
model.City = @event.City;
}
return View("~/Pages/Events/Components/LocationArea/Default.cshtml", model);
}
public class LocationAreaViewComponentModel
{
public Guid EventId { get; set; }
public bool IsRegistered { get; set; }
public bool IsOnline { get; set; }
public string OnlineLink { get; set; }
public string Country { get; set; }
public string City { 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();
});
})();

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

@ -1,8 +1,10 @@
@page "/events/{url}"
@inject IHtmlLocalizer<EventHubResource> L
@using System.Globalization
@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
@ -17,6 +19,10 @@
<abp-card-subtitle>
@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>
@if (!Model.Event.Language.IsNullOrWhiteSpace())
{
<p>@L["Language"]: <span class="text-muted"> @CultureInfo.GetCultureInfo(Model.Event.Language).EnglishName</span></p>
}
</abp-card-subtitle>
<abp-card-text class="mt-3">
@Model.Event.Description
@ -27,5 +33,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>

13
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,14 @@ else
<abp-input asp-for="Event.EndTime" />
<abp-input asp-for="Event.Description" />
<abp-input asp-for="Event.IsOnline" />
<div id="event-link-group" style="display: none">
<abp-input asp-for="Event.OnlineLink" />
</div>
<div id="event-location-group">
<abp-select asp-for="Event.CountryId" />
<abp-input asp-for="Event.City" />
</div>
<abp-select asp-for="Event.Language" />
<abp-input asp-for="Event.Capacity" />
<abp-button size="Large" button-type="Primary" type="submit" text="@L["Submit"].Value" />
</form>

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

@ -2,12 +2,15 @@
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Globalization;
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 NUglify.Helpers;
using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Form;
namespace EventHub.Web.Pages.Events
@ -18,6 +21,8 @@ namespace EventHub.Web.Pages.Events
public NewEventViewModel Event { get; set; }
public List<SelectListItem> Organizations { get; private set; }
public List<SelectListItem> Countries { get; private set; }
public List<SelectListItem> Languages { get; private set; }
private readonly IEventAppService _eventAppService;
private readonly IOrganizationAppService _organizationAppService;
@ -39,6 +44,8 @@ namespace EventHub.Web.Pages.Events
};
await FillOrganizationsAsync();
await FillCountriesAsync();
FillLanguages();
}
private async Task FillOrganizationsAsync()
@ -52,7 +59,36 @@ namespace EventHub.Web.Pages.Events
}
).ToList();
}
private async Task FillCountriesAsync()
{
var result = await _eventAppService.GetCountriesLookupAsync();
Countries = result.Select(
country => new SelectListItem
{
Value = country.Id.ToString(),
Text = country.Name
}
).ToList();
}
private void FillLanguages()
{
var result = CultureInfo.GetCultures(CultureTypes.NeutralCultures)
.DistinctBy(x => x.EnglishName)
.OrderBy(x => x.EnglishName)
.ToList();
result.Remove(result.Single(x => x.TwoLetterISOLanguageName == "iv")); // Invariant Language
Languages = result.Select(
cultureInfo => new SelectListItem
{
Value = cultureInfo.TwoLetterISOLanguageName,
Text = cultureInfo.EnglishName
}
).ToList();
}
public async Task<IActionResult> OnPostAsync()
{
try
@ -68,6 +104,8 @@ namespace EventHub.Web.Pages.Events
{
ShowAlert(exception);
await FillOrganizationsAsync();
await FillCountriesAsync();
FillLanguages();
return Page();
}
}
@ -94,7 +132,24 @@ namespace EventHub.Web.Pages.Events
public string Description { get; set; }
public bool IsOnline { get; set; }
[CanBeNull]
[StringLength(EventConsts.MaxOnlineLinkLength, MinimumLength = EventConsts.MinOnlineLinkLength)]
public string OnlineLink { get; set; }
[SelectItems(nameof(Countries))]
[DisplayName("Country")]
public Guid? CountryId { get; set; }
[SelectItems(nameof(Languages))]
[DisplayName("Language")]
public string Language { get; set; }
[CanBeNull]
[StringLength(EventConsts.MaxCityLength, MinimumLength = EventConsts.MinCityLength)]
public string City { get; set; }
[Range(1, int.MaxValue)]
public int? Capacity { get; set; }
}
}

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

@ -0,0 +1,14 @@
$(function () {
$("#Event_CountryId").prepend("<option value='' selected='selected'></option>");
$("#Event_Language").prepend("<option value='' selected='selected'></option>");
$('#Event_IsOnline').click(function() {
if ($(this).is(':checked')) {
$("#event-link-group").show();
$("#event-location-group").hide();
}else{
$("#event-link-group").hide();
$("#event-location-group").show();
}
});
});

47
test/EventHub.Application.Tests/Events/EventAppServiceTests.cs

@ -1,5 +1,6 @@
using System;
using System.Threading.Tasks;
using EventHub.Events.Registrations;
using Shouldly;
using Volo.Abp;
using Volo.Abp.Timing;
@ -10,11 +11,13 @@ namespace EventHub.Events
public class EventAppServiceTests : EventHubApplicationTestBase
{
private readonly IEventAppService _eventAppService;
private readonly IEventRegistrationAppService _eventRegistrationAppService;
private readonly EventHubTestData _testData;
public EventAppServiceTests()
{
_eventAppService = GetRequiredService<IEventAppService>();
_eventRegistrationAppService = GetRequiredService<IEventRegistrationAppService>();
_testData = GetRequiredService<EventHubTestData>();
}
@ -29,7 +32,9 @@ namespace EventHub.Events
Description = "In this event, we will introduce the ABP Framework and explore the fundamental features.",
StartTime = DateTime.Now.AddDays(1),
EndTime = DateTime.Now.AddDays(1).AddHours(3),
IsOnline = true
IsOnline = true,
Capacity = 2,
Language = "en"
}
);
@ -38,6 +43,8 @@ namespace EventHub.Events
eventDto.Description.ShouldBe("In this event, we will introduce the ABP Framework and explore the fundamental features.");
eventDto.IsOnline.ShouldBeTrue();
eventDto.UrlCode.ShouldNotBeNullOrWhiteSpace();
eventDto.Capacity.ShouldBe(2);
eventDto.Language.ShouldBe("en");
}
[Fact]
@ -112,5 +119,43 @@ namespace EventHub.Events
eventDetailDto.Title.ShouldBe(_testData.AbpBlazorPastEventTitle);
eventDetailDto.UrlCode.ShouldBe(_testData.AbpBlazorPastEventUrlCode);
}
[Fact]
public async Task Should_Get_Location()
{
var eventDto = await _eventAppService.CreateAsync(
new CreateEventDto
{
OrganizationId = _testData.OrganizationVolosoftId,
Title = "Introduction to the ABP Framework",
Description = "In this event, we will introduce the ABP Framework and explore the fundamental features.",
StartTime = DateTime.Now.AddDays(2),
EndTime = DateTime.Now.AddDays(2).AddHours(3),
IsOnline = true,
Capacity = 2,
Language = "en",
City = "Istanbul",
OnlineLink = "http://abp.io"
}
);
await _eventRegistrationAppService.RegisterAsync(eventDto.Id);
var result = await _eventAppService.GetLocationAsync(eventDto.Id);
result.ShouldNotBeNull();
result.IsOnline.ShouldBeTrue();
result.OnlineLink.ShouldBe("http://abp.io");
result.City.ShouldBeNull();
}
[Fact]
public async Task Should_Get_All_Countries()
{
var result = await _eventAppService.GetCountriesLookupAsync();
result.ShouldNotBeNull();
result.Count.ShouldBeGreaterThan(1);
}
}
}

43
test/EventHub.Application.Tests/Events/Registrations/EventRegistrationAppServiceTests.cs

@ -1,6 +1,9 @@
using System;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using NSubstitute;
using Shouldly;
using Volo.Abp;
using Volo.Abp.Domain.Repositories;
using Volo.Abp.Users;
using Xunit;
@ -12,19 +15,26 @@ namespace EventHub.Events.Registrations
private readonly IEventRegistrationAppService _eventRegistrationAppService;
private readonly IRepository<EventRegistration, Guid> _eventRegistrationRepository;
private readonly EventHubTestData _testData;
private readonly ICurrentUser _currentUser;
private ICurrentUser _currentUser;
public EventRegistrationAppServiceTests()
{
_eventRegistrationAppService = GetRequiredService<IEventRegistrationAppService>();
_eventRegistrationRepository = GetRequiredService<IRepository<EventRegistration, Guid>>();
_testData = GetRequiredService<EventHubTestData>();
_currentUser = GetRequiredService<ICurrentUser>();
}
protected override void AfterAddApplication(IServiceCollection services)
{
_currentUser = Substitute.For<ICurrentUser>();
services.AddSingleton(_currentUser);
}
[Fact]
public async Task Should_Register_To_An_Event()
{
Login(_testData.UserAdminId);
await _eventRegistrationAppService.RegisterAsync(
_testData.AbpMicroservicesFutureEventId
);
@ -38,6 +48,8 @@ namespace EventHub.Events.Registrations
[Fact]
public async Task Should_Unregister_From_An_Event()
{
Login(_testData.UserAdminId);
await WithUnitOfWorkAsync(async () =>
{
await _eventRegistrationRepository.InsertAsync(
@ -59,6 +71,27 @@ namespace EventHub.Events.Registrations
).ShouldBeNull();
}
[Fact]
public async Task Should_Not_Be_Registered_For_Capacity_Is_Full()
{
Login(_testData.UserAdminId);
await _eventRegistrationAppService.RegisterAsync(
_testData.AbpMicroservicesFutureEventId
);
Login(_testData.UserJohnId);
var exception = await Assert.ThrowsAsync<BusinessException>(async () =>
{
await _eventRegistrationAppService.RegisterAsync(
_testData.AbpMicroservicesFutureEventId
);
});
exception.Code.ShouldBe(EventHubErrorCodes.CapacityOfEventFull);
}
[Fact]
public async Task Should_Get_List_Of_Attendees()
{
@ -99,5 +132,11 @@ namespace EventHub.Events.Registrations
);
});
}
private void Login(Guid userId)
{
_currentUser.Id.Returns(userId);
_currentUser.IsAuthenticated.Returns(true);
}
}
}

20
test/EventHub.Domain.Tests/Events/EventTests.cs

@ -25,5 +25,25 @@ namespace EventHub.Events
exception.Code.ShouldBe(EventHubErrorCodes.EventEndTimeCantBeEarlierThanStartTime);
}
[Fact]
public void Should_Be_CountryId_And_City_Null_If_Event_Online()
{
var @event = new Event(
Guid.NewGuid(),
Guid.NewGuid(),
"1a8j3v0d",
"Introduction to the ABP Framework",
DateTime.Now,
DateTime.Now.AddDays(2),
"In this event, we will introduce the ABP Framework and explore the fundamental features.");
@event.SetLocation(true, "http://abp.io", Guid.NewGuid(), "Istanbul");
@event.IsOnline.ShouldBeTrue();
@event.OnlineLink.ShouldBe("http://abp.io");
@event.CountryId.ShouldBeNull();
@event.City.ShouldBeNull();
}
}
}

3
test/EventHub.TestBase/EventHubTestDataSeedContributor.cs

@ -100,6 +100,9 @@ namespace EventHub
_clock.Now.ClearTime().AddDays(1).AddHours(17),
"This is a future event about the ABP Framework and Microservices that is set for tomorrow."
)
{
Capacity = 1
}
);
}
}

Loading…
Cancel
Save