Browse Source

Show country and city to registered users if event is not online

pull/20/head
Berkan 6 years ago
parent
commit
8df95c294a
  1. 10
      src/EventHub.Application.Contracts/Events/CountryLookupDto.cs
  2. 6
      src/EventHub.Application.Contracts/Events/CreateEventDto.cs
  3. 7
      src/EventHub.Application.Contracts/Events/EventLocationDto.cs
  4. 3
      src/EventHub.Application.Contracts/Events/IEventAppService.cs
  5. 6
      src/EventHub.Application/EventHubApplicationAutoMapperProfile.cs
  6. 30
      src/EventHub.Application/Events/EventAppService.cs
  7. 7
      src/EventHub.Domain.Shared/Countries/CountryConsts.cs
  8. 3
      src/EventHub.Domain.Shared/Events/EventConsts.cs
  9. 3
      src/EventHub.Domain.Shared/Localization/EventHub/en.json
  10. 24
      src/EventHub.Domain/Countries/Country.cs
  11. 218
      src/EventHub.Domain/EventHubDataSeedContributor.cs
  12. 35
      src/EventHub.Domain/Events/Event.cs
  13. 2534
      src/EventHub.EntityFrameworkCore.DbMigrations/Migrations/20210208140845_Added_Countries.Designer.cs
  14. 64
      src/EventHub.EntityFrameworkCore.DbMigrations/Migrations/20210208140845_Added_Countries.cs
  15. 2538
      src/EventHub.EntityFrameworkCore.DbMigrations/Migrations/20210208141144_Added_City_To_Event.Designer.cs
  16. 24
      src/EventHub.EntityFrameworkCore.DbMigrations/Migrations/20210208141144_Added_City_To_Event.cs
  17. 32
      src/EventHub.EntityFrameworkCore.DbMigrations/Migrations/EventHubMigrationsDbContextModelSnapshot.cs
  18. 6
      src/EventHub.EntityFrameworkCore/EntityFrameworkCore/EventHubDbContext.cs
  19. 17
      src/EventHub.EntityFrameworkCore/EntityFrameworkCore/EventHubDbContextModelCreatingExtensions.cs
  20. 21
      src/EventHub.Web/Pages/Events/Components/LocationArea/Default.cshtml
  21. 7
      src/EventHub.Web/Pages/Events/Components/LocationArea/LocationAreaViewComponent.cs
  22. 6
      src/EventHub.Web/Pages/Events/New.cshtml
  23. 24
      src/EventHub.Web/Pages/Events/New.cshtml.cs
  24. 8
      src/EventHub.Web/Pages/Events/New.js

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

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

@ -28,6 +28,12 @@ namespace EventHub.Events
[CanBeNull] [CanBeNull]
[StringLength(EventConsts.MaxLinkLength, MinimumLength = EventConsts.MinLinkLength)] [StringLength(EventConsts.MaxLinkLength, MinimumLength = EventConsts.MinLinkLength)]
public string Link { get; set; } public string Link { get; set; }
public Guid? CountryId { get; set; }
[CanBeNull]
[StringLength(EventConsts.MaxCityLength, MinimumLength = EventConsts.MinCityLength)]
public string City { get; set; }
[Range(0, int.MaxValue)] [Range(0, int.MaxValue)]
public int? Capacity { get; set; } public int? Capacity { get; set; }

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

@ -7,8 +7,13 @@ namespace EventHub.Events
{ {
public bool IsOnline { get; set; } public bool IsOnline { get; set; }
public bool IsRegistered { get; set; }
public string Link { get; set; } public string Link { get; set; }
public bool IsRegistered { get; set; } public string Country { get; set; }
public string City { get; set; }
} }
} }

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

@ -1,4 +1,5 @@
using System; using System;
using System.Collections.Generic;
using System.Threading.Tasks; using System.Threading.Tasks;
using Volo.Abp.Application.Dtos; using Volo.Abp.Application.Dtos;
using Volo.Abp.Application.Services; using Volo.Abp.Application.Services;
@ -14,5 +15,7 @@ namespace EventHub.Events
Task<EventDetailDto> GetByUrlCodeAsync(string urlCode); Task<EventDetailDto> GetByUrlCodeAsync(string urlCode);
Task<EventLocationDto> GetLocationAsync(Guid id); Task<EventLocationDto> GetLocationAsync(Guid id);
Task<List<CountryLookupDto>> GetCountriesLookupAsync();
} }
} }

6
src/EventHub.Application/EventHubApplicationAutoMapperProfile.cs

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

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

@ -1,6 +1,8 @@
using System; using System;
using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using EventHub.Countries;
using EventHub.Events.Registrations; using EventHub.Events.Registrations;
using EventHub.Organizations; using EventHub.Organizations;
using EventHub.Users; using EventHub.Users;
@ -19,19 +21,22 @@ namespace EventHub.Events
private readonly IRepository<Event, Guid> _eventRepository; private readonly IRepository<Event, Guid> _eventRepository;
private readonly IRepository<Organization, Guid> _organizationRepository; private readonly IRepository<Organization, Guid> _organizationRepository;
private readonly IRepository<AppUser, Guid> _userRepository; private readonly IRepository<AppUser, Guid> _userRepository;
private readonly IRepository<Country, Guid> _countriesRepository;
public EventAppService( public EventAppService(
EventManager eventManager, EventManager eventManager,
EventRegistrationManager eventRegistrationManager, EventRegistrationManager eventRegistrationManager,
IRepository<Event, Guid> eventRepository, IRepository<Event, Guid> eventRepository,
IRepository<Organization, Guid> organizationRepository, IRepository<Organization, Guid> organizationRepository,
IRepository<AppUser, Guid> userRepository) IRepository<AppUser, Guid> userRepository,
IRepository<Country, Guid> countriesRepository)
{ {
_eventManager = eventManager; _eventManager = eventManager;
_eventRegistrationManager = eventRegistrationManager; _eventRegistrationManager = eventRegistrationManager;
_eventRepository = eventRepository; _eventRepository = eventRepository;
_organizationRepository = organizationRepository; _organizationRepository = organizationRepository;
_userRepository = userRepository; _userRepository = userRepository;
_countriesRepository = countriesRepository;
} }
[Authorize] [Authorize]
@ -53,8 +58,7 @@ namespace EventHub.Events
input.Description input.Description
); );
@event.IsOnline = input.IsOnline; @event.SetLocation(input.IsOnline, input.Link, input.CountryId, input.City);
@event.Link = input.Link;
@event.Capacity = input.Capacity; @event.Capacity = input.Capacity;
await _eventRepository.InsertAsync(@event); await _eventRepository.InsertAsync(@event);
@ -142,9 +146,29 @@ namespace EventHub.Events
if (!dto.IsRegistered) if (!dto.IsRegistered)
{ {
dto.Link = null; dto.Link = null;
dto.City = null;
}
if (dto.IsRegistered && @event.CountryId.HasValue)
{
dto.Country = (await _countriesRepository.GetAsync(@event.CountryId.Value)).Name;
} }
return dto; 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;
}
}

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

@ -14,5 +14,8 @@
public const int MinLinkLength = 4; public const int MinLinkLength = 4;
public const int MaxLinkLength = 2000; public const int MaxLinkLength = 2000;
public const int MinCityLength = 2;
public const int MaxCityLength = 32;
} }
} }

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

@ -51,6 +51,7 @@
"EventHub:CapacityOfEventFull": "\"{EventTitle}\" event capacity is full!", "EventHub:CapacityOfEventFull": "\"{EventTitle}\" event capacity is full!",
"GoToEventAddress": "Go to Event Address", "GoToEventAddress": "Go to Event Address",
"AttendeesCanSeeEventLocation": "Only attendees can see the event's {0}.", "AttendeesCanSeeEventLocation": "Only attendees can see the event's {0}.",
"LoginToSeeLocation": "Login to see location" "LoginToSeeLocation": "Login to see location",
"LocationHasNotSpecifiedYet": "Event {0} has not been specified yet."
} }
} }

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;
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading.Tasks; using System.Threading.Tasks;
using EventHub.Countries;
using EventHub.Events; using EventHub.Events;
using EventHub.Events.Registrations; using EventHub.Events.Registrations;
using EventHub.Organizations; using EventHub.Organizations;
@ -23,6 +24,7 @@ namespace EventHub
private readonly EventManager _eventManager; private readonly EventManager _eventManager;
private readonly EventRegistrationManager _eventRegistrationManager; private readonly EventRegistrationManager _eventRegistrationManager;
private readonly IRepository<AppUser, Guid> _userRepository; private readonly IRepository<AppUser, Guid> _userRepository;
private readonly IRepository<Country, Guid> _countryRepository;
public EventHubDataSeedContributor( public EventHubDataSeedContributor(
IGuidGenerator guidGenerator, IGuidGenerator guidGenerator,
@ -32,8 +34,8 @@ namespace EventHub
IRepository<Event, Guid> eventRepository, IRepository<Event, Guid> eventRepository,
EventManager eventManager, EventManager eventManager,
EventRegistrationManager eventRegistrationManager, EventRegistrationManager eventRegistrationManager,
IRepository<AppUser, Guid> userRepository IRepository<AppUser, Guid> userRepository,
) IRepository<Country, Guid> countryRepository)
{ {
_guidGenerator = guidGenerator; _guidGenerator = guidGenerator;
_identityUserManager = identityUserManager; _identityUserManager = identityUserManager;
@ -43,6 +45,7 @@ namespace EventHub
_eventManager = eventManager; _eventManager = eventManager;
_eventRegistrationManager = eventRegistrationManager; _eventRegistrationManager = eventRegistrationManager;
_userRepository = userRepository; _userRepository = userRepository;
_countryRepository = countryRepository;
} }
public async Task SeedAsync(DataSeedContext context) public async Task SeedAsync(DataSeedContext context)
@ -52,6 +55,7 @@ namespace EventHub
await SeedOrganizationsAsync(); await SeedOrganizationsAsync();
await SeedEventsAsync(); await SeedEventsAsync();
#endif #endif
await SeedCountriesAsync();
} }
private async Task SeedUsersAsync() private async Task SeedUsersAsync()
@ -350,5 +354,215 @@ namespace EventHub
await _eventRegistrationManager.RegisterAsync(upcomingEvent15, userMark); await _eventRegistrationManager.RegisterAsync(upcomingEvent15, userMark);
await _eventRegistrationManager.RegisterAsync(upcomingEvent15, userSandra); 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);
}
} }
} }

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

@ -20,16 +20,20 @@ namespace EventHub.Events
public string Description { get; private set; } public string Description { get; private set; }
public bool IsOnline { get; set; } public bool IsOnline { get; private set; }
public string Link { get; private set; }
public Guid? CountryId { get; private set; }
public string City { get; private set; }
public int? Capacity { get; set; } public int? Capacity { get; set; }
public bool IsRemindingEmailSent { get; set; } public bool IsRemindingEmailSent { get; set; }
public bool IsEmailSentToMembers { get; set; } public bool IsEmailSentToMembers { get; set; }
public string Link { get; set; }
private Event() private Event()
{ {
@ -76,5 +80,28 @@ namespace EventHub.Events
EndTime = endTime; EndTime = endTime;
return this; return this;
} }
public Event SetLocation(bool isOnline, string link, Guid? countryId, string city)
{
IsOnline = isOnline;
if (isOnline)
{
if (!link.IsNullOrWhiteSpace())
{
Link = link;
}
return this;
}
if (countryId.HasValue && !city.IsNullOrWhiteSpace())
{
CountryId = countryId;
City = city;
}
return this;
}
} }
} }

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

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

@ -21,6 +21,24 @@ namespace EventHub.Migrations
.HasAnnotation("Relational:MaxIdentifierLength", 128) .HasAnnotation("Relational:MaxIdentifierLength", 128)
.HasAnnotation("ProductVersion", "5.0.2"); .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 => modelBuilder.Entity("EventHub.Events.Event", b =>
{ {
b.Property<Guid>("Id") b.Property<Guid>("Id")
@ -30,12 +48,19 @@ namespace EventHub.Migrations
b.Property<int?>("Capacity") b.Property<int?>("Capacity")
.HasColumnType("int"); .HasColumnType("int");
b.Property<string>("City")
.HasMaxLength(32)
.HasColumnType("nvarchar(32)");
b.Property<string>("ConcurrencyStamp") b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken() .IsConcurrencyToken()
.HasMaxLength(40) .HasMaxLength(40)
.HasColumnType("nvarchar(40)") .HasColumnType("nvarchar(40)")
.HasColumnName("ConcurrencyStamp"); .HasColumnName("ConcurrencyStamp");
b.Property<Guid?>("CountryId")
.HasColumnType("uniqueidentifier");
b.Property<DateTime>("CreationTime") b.Property<DateTime>("CreationTime")
.HasColumnType("datetime2") .HasColumnType("datetime2")
.HasColumnName("CreationTime"); .HasColumnName("CreationTime");
@ -114,6 +139,8 @@ namespace EventHub.Migrations
b.HasKey("Id"); b.HasKey("Id");
b.HasIndex("CountryId");
b.HasIndex("StartTime"); b.HasIndex("StartTime");
b.HasIndex("UrlCode"); b.HasIndex("UrlCode");
@ -2104,6 +2131,11 @@ namespace EventHub.Migrations
modelBuilder.Entity("EventHub.Events.Event", b => modelBuilder.Entity("EventHub.Events.Event", b =>
{ {
b.HasOne("EventHub.Countries.Country", null)
.WithMany()
.HasForeignKey("CountryId")
.OnDelete(DeleteBehavior.NoAction);
b.HasOne("EventHub.Organizations.Organization", null) b.HasOne("EventHub.Organizations.Organization", null)
.WithMany() .WithMany()
.HasForeignKey("OrganizationId") .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.Events.Registrations;
using EventHub.Organizations; using EventHub.Organizations;
using EventHub.Organizations.Memberships; using EventHub.Organizations.Memberships;
@ -29,7 +30,8 @@ namespace EventHub.EntityFrameworkCore
public DbSet<OrganizationMembership> OrganizationMemberships { get; set; } public DbSet<OrganizationMembership> OrganizationMemberships { get; set; }
public DbSet<Event> Events { get; set; } public DbSet<Event> Events { get; set; }
public DbSet<EventRegistration> EventRegistrations { get; set; } public DbSet<EventRegistration> EventRegistrations { get; set; }
public DbSet<Country> Countries { get; set; }
public EventHubDbContext(DbContextOptions<EventHubDbContext> options) public EventHubDbContext(DbContextOptions<EventHubDbContext> options)
: base(options) : base(options)
{ {

17
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.Events.Registrations;
using EventHub.Organizations; using EventHub.Organizations;
using EventHub.Organizations.Memberships; using EventHub.Organizations.Memberships;
@ -65,8 +66,11 @@ namespace EventHub.EntityFrameworkCore
b.Property(x => x.UrlCode).IsRequired().HasMaxLength(EventConsts.UrlCodeLength); b.Property(x => x.UrlCode).IsRequired().HasMaxLength(EventConsts.UrlCodeLength);
b.Property(x => x.Url).IsRequired().HasMaxLength(EventConsts.MaxUrlLength); b.Property(x => x.Url).IsRequired().HasMaxLength(EventConsts.MaxUrlLength);
b.Property(x => x.Link).HasMaxLength(EventConsts.MaxLinkLength); b.Property(x => x.Link).HasMaxLength(EventConsts.MaxLinkLength);
b.Property(x => x.City).HasMaxLength(EventConsts.MaxCityLength);
b.HasOne<Organization>().WithMany().HasForeignKey(x => x.OrganizationId).IsRequired().OnDelete(DeleteBehavior.NoAction); 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 => new {x.OrganizationId, x.StartTime});
b.HasIndex(x => x.StartTime); b.HasIndex(x => x.StartTime);
@ -88,6 +92,17 @@ namespace EventHub.EntityFrameworkCore
b.HasIndex(x => new {x.EventId, x.UserId}); 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});
});
} }
} }
} }

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

@ -8,9 +8,26 @@
@if (Model.IsRegistered) @if (Model.IsRegistered)
{ {
if (Model.IsOnline && Model.Link != null) if (Model.IsOnline)
{
if (Model.Link != null)
{
<a href="@Model.Link">@L["GoToEventAddress"]</a>
}
else
{
<p>@L["LocationHasNotSpecifiedYet", "URL"]</p>
}
}else
{ {
<a href="@Model.Link">@L["GoToEventAddress"]</a> if (Model.Country != null && Model.City != null)
{
<p>@Model.Country/@Model.City</p>
}
else
{
<p>@L["LocationHasNotSpecifiedYet", "location"]</p>
}
} }
} }
else else

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

@ -37,7 +37,7 @@ namespace EventHub.Web.Pages.Events.Components.LocationArea
var model = new LocationAreaViewComponentModel var model = new LocationAreaViewComponentModel
{ {
EventId = eventId, EventId = eventId,
IsLoggedIn = isLoggedIn, IsRegistered = false
}; };
if (isLoggedIn) if (isLoggedIn)
@ -47,6 +47,8 @@ namespace EventHub.Web.Pages.Events.Components.LocationArea
model.IsOnline = @event.IsOnline; model.IsOnline = @event.IsOnline;
model.IsRegistered = @event.IsRegistered; model.IsRegistered = @event.IsRegistered;
model.Link = @event.Link; model.Link = @event.Link;
model.Country = @event.Country;
model.City = @event.City;
} }
return View("~/Pages/Events/Components/LocationArea/Default.cshtml", model); return View("~/Pages/Events/Components/LocationArea/Default.cshtml", model);
@ -55,10 +57,11 @@ namespace EventHub.Web.Pages.Events.Components.LocationArea
public class LocationAreaViewComponentModel public class LocationAreaViewComponentModel
{ {
public Guid EventId { get; set; } public Guid EventId { get; set; }
public bool IsLoggedIn { get; set; }
public bool IsRegistered { get; set; } public bool IsRegistered { get; set; }
public bool IsOnline { get; set; } public bool IsOnline { get; set; }
public string Link { get; set; } public string Link { get; set; }
public string Country { get; set; }
public string City { get; set; }
} }
} }
} }

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

@ -25,9 +25,13 @@ else
<abp-input asp-for="Event.EndTime" /> <abp-input asp-for="Event.EndTime" />
<abp-input asp-for="Event.Description" /> <abp-input asp-for="Event.Description" />
<abp-input asp-for="Event.IsOnline" /> <abp-input asp-for="Event.IsOnline" />
<div id="event-link-form" style="display: none"> <div id="event-link-group" style="display: none">
<abp-input asp-for="Event.Link" /> <abp-input asp-for="Event.Link" />
</div> </div>
<div id="event-location-group">
<abp-select asp-for="Event.CountryId" />
<abp-input asp-for="Event.City" />
</div>
<abp-input asp-for="Event.Capacity" /> <abp-input asp-for="Event.Capacity" />
<abp-button size="Large" button-type="Primary" type="submit" text="@L["Submit"].Value" /> <abp-button size="Large" button-type="Primary" type="submit" text="@L["Submit"].Value" />
</form> </form>

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

@ -19,6 +19,7 @@ namespace EventHub.Web.Pages.Events
public NewEventViewModel Event { get; set; } public NewEventViewModel Event { get; set; }
public List<SelectListItem> Organizations { get; private set; } public List<SelectListItem> Organizations { get; private set; }
public List<SelectListItem> Countries { get; private set; }
private readonly IEventAppService _eventAppService; private readonly IEventAppService _eventAppService;
private readonly IOrganizationAppService _organizationAppService; private readonly IOrganizationAppService _organizationAppService;
@ -40,6 +41,7 @@ namespace EventHub.Web.Pages.Events
}; };
await FillOrganizationsAsync(); await FillOrganizationsAsync();
await FillCountriesAsync();
} }
private async Task FillOrganizationsAsync() private async Task FillOrganizationsAsync()
@ -53,6 +55,19 @@ namespace EventHub.Web.Pages.Events
} }
).ToList(); ).ToList();
} }
private async Task FillCountriesAsync()
{
var result = await _eventAppService.GetCountriesLookupAsync();
Countries = result.Select(
country => new SelectListItem
{
Value = country.Id.ToString(),
Text = country.Name
}
).ToList();
}
public async Task<IActionResult> OnPostAsync() public async Task<IActionResult> OnPostAsync()
{ {
@ -69,6 +84,7 @@ namespace EventHub.Web.Pages.Events
{ {
ShowAlert(exception); ShowAlert(exception);
await FillOrganizationsAsync(); await FillOrganizationsAsync();
await FillCountriesAsync();
return Page(); return Page();
} }
} }
@ -99,6 +115,14 @@ namespace EventHub.Web.Pages.Events
[CanBeNull] [CanBeNull]
[StringLength(EventConsts.MaxLinkLength, MinimumLength = EventConsts.MinLinkLength)] [StringLength(EventConsts.MaxLinkLength, MinimumLength = EventConsts.MinLinkLength)]
public string Link { get; set; } public string Link { get; set; }
[SelectItems(nameof(Countries))]
[DisplayName("Country")]
public Guid? CountryId { get; set; }
[CanBeNull]
[StringLength(EventConsts.MaxCityLength, MinimumLength = EventConsts.MinCityLength)]
public string City { get; set; }
public int? Capacity { get; set; } public int? Capacity { get; set; }
} }

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

@ -1,9 +1,13 @@
$(function () { $(function () {
$("#Event_CountryId").prepend("<option value='' selected='selected'></option>");
$('#Event_IsOnline').click(function() { $('#Event_IsOnline').click(function() {
if ($(this).is(':checked')) { if ($(this).is(':checked')) {
$("#event-link-form").show(); $("#event-link-group").show();
$("#event-location-group").hide();
}else{ }else{
$("#event-link-form").hide(); $("#event-link-group").hide();
$("#event-location-group").show();
} }
}); });
}); });
Loading…
Cancel
Save