Browse Source

Add language to event

pull/20/head
Berkan 6 years ago
parent
commit
ae61ab3322
  1. 6
      src/EventHub.Application.Contracts/Events/CreateEventDto.cs
  2. 2
      src/EventHub.Application.Contracts/Events/EventDetailDto.cs
  3. 2
      src/EventHub.Application.Contracts/Events/EventDto.cs
  4. 1
      src/EventHub.Application/Events/EventAppService.cs
  5. 3
      src/EventHub.Domain.Shared/Events/EventConsts.cs
  6. 4
      src/EventHub.Domain/Events/Event.cs
  7. 2542
      src/EventHub.EntityFrameworkCore.DbMigrations/Migrations/20210209072715_Added_Language_To_Event.Designer.cs
  8. 24
      src/EventHub.EntityFrameworkCore.DbMigrations/Migrations/20210209072715_Added_Language_To_Event.cs
  9. 4
      src/EventHub.EntityFrameworkCore.DbMigrations/Migrations/EventHubMigrationsDbContextModelSnapshot.cs
  10. 1
      src/EventHub.EntityFrameworkCore/EntityFrameworkCore/EventHubDbContextModelCreatingExtensions.cs
  11. 5
      src/EventHub.Web/Pages/Events/Detail.cshtml
  12. 1
      src/EventHub.Web/Pages/Events/New.cshtml
  13. 26
      src/EventHub.Web/Pages/Events/New.cshtml.cs
  14. 1
      src/EventHub.Web/Pages/Events/New.js

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

@ -34,7 +34,11 @@ namespace EventHub.Events
[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(0, int.MaxValue)]
[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; }
}
}

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

@ -59,6 +59,7 @@ namespace EventHub.Events
);
@event.SetLocation(input.IsOnline, input.Link, input.CountryId, input.City);
@event.Language = input.Language;
@event.Capacity = input.Capacity;
await _eventRepository.InsertAsync(@event);

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

@ -17,5 +17,8 @@
public const int MinCityLength = 2;
public const int MaxCityLength = 32;
public const int MinLanguageLength = 2;
public const int MaxLanguageLength = 16;
}
}

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

@ -28,12 +28,14 @@ namespace EventHub.Events
public string City { get; private set; }
public string Language { get; set; }
public int? Capacity { get; set; }
public bool IsRemindingEmailSent { get; set; }
public bool IsEmailSentToMembers { get; set; }
private Event()
{

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

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

@ -104,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");

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

@ -67,6 +67,7 @@ namespace EventHub.EntityFrameworkCore
b.Property(x => x.Url).IsRequired().HasMaxLength(EventConsts.MaxUrlLength);
b.Property(x => x.Link).HasMaxLength(EventConsts.MaxLinkLength);
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);

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

@ -1,5 +1,6 @@
@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
@ -18,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

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

@ -32,6 +32,7 @@ else
<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>

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

@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Globalization;
using System.Linq;
using System.Threading.Tasks;
using EventHub.Events;
@ -9,6 +10,7 @@ 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
@ -20,6 +22,7 @@ namespace EventHub.Web.Pages.Events
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;
@ -42,6 +45,7 @@ namespace EventHub.Web.Pages.Events
await FillOrganizationsAsync();
await FillCountriesAsync();
FillLanguages();
}
private async Task FillOrganizationsAsync()
@ -69,6 +73,22 @@ namespace EventHub.Web.Pages.Events
).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
@ -85,6 +105,7 @@ namespace EventHub.Web.Pages.Events
ShowAlert(exception);
await FillOrganizationsAsync();
await FillCountriesAsync();
FillLanguages();
return Page();
}
}
@ -119,11 +140,16 @@ namespace EventHub.Web.Pages.Events
[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; }
}
}

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

@ -1,5 +1,6 @@
$(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')) {

Loading…
Cancel
Save