diff --git a/src/EventHub.Application.Contracts/Events/EventInListDto.cs b/src/EventHub.Application.Contracts/Events/EventInListDto.cs index 69e3055..b919bd0 100644 --- a/src/EventHub.Application.Contracts/Events/EventInListDto.cs +++ b/src/EventHub.Application.Contracts/Events/EventInListDto.cs @@ -32,7 +32,7 @@ namespace EventHub.Events public string Url { get; set; } - public DateTime CreationTime { get; } + public DateTime CreationTime { get; set; } public DateTime? LastModificationTime { get; set; } } diff --git a/src/EventHub.Application.Contracts/Events/IEventAppService.cs b/src/EventHub.Application.Contracts/Events/IEventAppService.cs index c2fd720..4390f28 100644 --- a/src/EventHub.Application.Contracts/Events/IEventAppService.cs +++ b/src/EventHub.Application.Contracts/Events/IEventAppService.cs @@ -24,6 +24,8 @@ namespace EventHub.Events Task IsEventOwnerAsync(Guid id); Task UpdateAsync(Guid id, UpdateEventDto input); + + Task PublishAsync(Guid id); Task AddTrackAsync(Guid id, AddTractDto input); diff --git a/src/EventHub.Application.Contracts/Events/UpdateEventDto.cs b/src/EventHub.Application.Contracts/Events/UpdateEventDto.cs index 49a1a49..233b9e1 100644 --- a/src/EventHub.Application.Contracts/Events/UpdateEventDto.cs +++ b/src/EventHub.Application.Contracts/Events/UpdateEventDto.cs @@ -7,8 +7,6 @@ namespace EventHub.Events { public class UpdateEventDto { - //TODO: Add OrganizationId - [Required] [StringLength(EventConsts.MaxTitleLength, MinimumLength = EventConsts.MinTitleLength)] public string Title { get; set; } diff --git a/src/EventHub.Application/Events/EventAppService.cs b/src/EventHub.Application/Events/EventAppService.cs index 3d08249..15e8a5c 100644 --- a/src/EventHub.Application/Events/EventAppService.cs +++ b/src/EventHub.Application/Events/EventAppService.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Security.Authentication; using System.Threading.Tasks; using EventHub.Countries; using EventHub.Events.Registrations; @@ -181,7 +182,7 @@ namespace EventHub.Events { if (!CurrentUser.Id.HasValue) { - throw new AbpAuthorizationException(); + throw new AuthenticationException(); } await CheckIfValidOwnerAsync(@event); @@ -281,6 +282,19 @@ namespace EventHub.Events await _eventRepository.UpdateAsync(@event); } + [Authorize] + public async Task PublishAsync(Guid id) + { + var @event = await _eventRepository.GetAsync(id); + await CheckIfValidOwnerAsync(@event); + + @event.Publish(); + + await _eventRepository.UpdateAsync(@event, true); + + return @event.UrlCode; + } + [Authorize] public async Task AddTrackAsync(Guid id, AddTractDto input) { diff --git a/src/EventHub.Domain.Shared/EventHubErrorCodes.cs b/src/EventHub.Domain.Shared/EventHubErrorCodes.cs index b68dbce..76e0b0a 100644 --- a/src/EventHub.Domain.Shared/EventHubErrorCodes.cs +++ b/src/EventHub.Domain.Shared/EventHubErrorCodes.cs @@ -19,5 +19,6 @@ public const string TrackNameAlreadyExist = "EventHub:TrackNameAlreadyExist"; public const string TrackNotFound = "EventHub:TrackNotFound"; public const string SessionNotFound = "EventHub:SessionNotFound"; + public const string DraftEventNotFound = "EventHub:DraftEventNotFound"; } } diff --git a/src/EventHub.Domain.Shared/Events/EventConsts.cs b/src/EventHub.Domain.Shared/Events/EventConsts.cs index ab6aba1..5ee9254 100644 --- a/src/EventHub.Domain.Shared/Events/EventConsts.cs +++ b/src/EventHub.Domain.Shared/Events/EventConsts.cs @@ -1,32 +1,32 @@ namespace EventHub.Events { - public static class EventConsts - { - public const string DefaultSorting = "Title desc"; + public static class EventConsts + { + public const string DefaultSorting = "Title desc"; - public const int UrlCodeLength = 8; - public const int MaxTitleInUrlLength = 60; - public const int MaxUrlLength = MaxTitleInUrlLength + 1 + UrlCodeLength; //Format: {Title}-{UrlCode} + public const int UrlCodeLength = 8; + public const int MaxTitleInUrlLength = 60; + public const int MaxUrlLength = MaxTitleInUrlLength + 1 + UrlCodeLength; //Format: {Title}-{UrlCode} - public const int MinTitleLength = 8; - public const int MaxTitleLength = 128; + public const int MinTitleLength = 8; + public const int MaxTitleLength = 128; - public const int MinDescriptionLength = 50; - public const int MaxDescriptionLength = 2000; + public const int MinDescriptionLength = 50; + public const int MaxDescriptionLength = 2000; - public const int MinOnlineLinkLength = 4; - public const int MaxOnlineLinkLength = 2000; + public const int MinOnlineLinkLength = 4; + public const int MaxOnlineLinkLength = 2000; - public const int MinCityLength = 2; - public const int MaxCityLength = 32; + public const int MinCityLength = 2; + public const int MaxCityLength = 32; - public const int MinLanguageLength = 2; - public const int MaxLanguageLength = 16; + public const int MinLanguageLength = 2; + public const int MaxLanguageLength = 16; - public const int MaxTimingChangeCountForUser = 2; + public const int MaxTimingChangeCountForUser = 2; - public const int MaxCoverImageFileSize = 5 * 1024 * 1024; + public const int MaxCoverImageFileSize = 5 * 1024 * 1024; - public static string[] AllowedCoverImageExtensions = { ".jpg", ".png" }; - } + public static string[] AllowedCoverImageExtensions = { ".jpg", ".png" }; + } } diff --git a/src/EventHub.Domain.Shared/Localization/EventHub/en.json b/src/EventHub.Domain.Shared/Localization/EventHub/en.json index 9b88b52..dcf7d34 100644 --- a/src/EventHub.Domain.Shared/Localization/EventHub/en.json +++ b/src/EventHub.Domain.Shared/Localization/EventHub/en.json @@ -157,6 +157,7 @@ "EventHub:TrackNotFound": "The track not found!", "EventHub:SessionNotFound": "The session not found!", "EventHub:SessionTimeShouldBeInTheEventTime": "Session time should be in the event time!", - "EventHub:SessionTimeConflictsWithAnExistingSession": "Session time conflicts with an existing session!" + "EventHub:SessionTimeConflictsWithAnExistingSession": "Session time conflicts with an existing session!", + "EventHub:DraftEventNotFound": "The draft event not found!" } } diff --git a/src/EventHub.Domain.Shared/Web/EventHubUrlOptions.cs b/src/EventHub.Domain.Shared/Web/EventHubUrlOptions.cs index 36f16d6..72037e6 100644 --- a/src/EventHub.Domain.Shared/Web/EventHubUrlOptions.cs +++ b/src/EventHub.Domain.Shared/Web/EventHubUrlOptions.cs @@ -2,64 +2,64 @@ namespace EventHub.Web { - public class EventHubUrlOptions - { - private const string ConfigurationName = "AppUrls"; - private const string AccountDefaultValue = "https://localhost:44313"; - private const string AdminDefaultValue = "https://localhost:44307"; - private const string WwwDefaultValue = "https://localhost:44308"; - private const string ApiDefaultValue = "https://localhost:44362"; - private const string ApiInternalDefaultValue = ApiDefaultValue; - private const string AdminApiDefaultValue = "https://localhost:44305"; + public class EventHubUrlOptions + { + private const string ConfigurationName = "AppUrls"; + private const string AccountDefaultValue = "https://localhost:44313"; + private const string AdminDefaultValue = "https://localhost:44307"; + private const string WwwDefaultValue = "https://localhost:44308"; + private const string ApiDefaultValue = "https://localhost:44362"; + private const string ApiInternalDefaultValue = ApiDefaultValue; + private const string AdminApiDefaultValue = "https://localhost:44305"; - public string Account { get; set; } = AccountDefaultValue; - public string Www { get; set; } = WwwDefaultValue; - public string Api { get; set; } = ApiDefaultValue; - public string ApiInternal { get; set; } = ApiInternalDefaultValue; - public string Admin { get; set; } = AdminDefaultValue; - public string AdminApi { get; set; } = AdminApiDefaultValue; + public string Account { get; set; } = AccountDefaultValue; + public string Www { get; set; } = WwwDefaultValue; + public string Api { get; set; } = ApiDefaultValue; + public string ApiInternal { get; set; } = ApiInternalDefaultValue; + public string Admin { get; set; } = AdminDefaultValue; + public string AdminApi { get; set; } = AdminApiDefaultValue; - public static string GetAccountConfigValue(IConfiguration configuration) - { - return GetConfigValue(configuration, nameof(Account), AccountDefaultValue); - } + public static string GetAccountConfigValue(IConfiguration configuration) + { + return GetConfigValue(configuration, nameof(Account), AccountDefaultValue); + } - public static string GetWwwConfigValue(IConfiguration configuration) - { - return GetConfigValue(configuration, nameof(Www), WwwDefaultValue); - } + public static string GetWwwConfigValue(IConfiguration configuration) + { + return GetConfigValue(configuration, nameof(Www), WwwDefaultValue); + } - public static string GetApiInternalConfigValue(IConfiguration configuration) - { - return GetConfigValue(configuration, nameof(ApiInternal), ApiInternalDefaultValue); - } + public static string GetApiInternalConfigValue(IConfiguration configuration) + { + return GetConfigValue(configuration, nameof(ApiInternal), ApiInternalDefaultValue); + } - public static string GetApiConfigValue(IConfiguration configuration) - { - return GetConfigValue(configuration, nameof(Api), ApiDefaultValue); - } + public static string GetApiConfigValue(IConfiguration configuration) + { + return GetConfigValue(configuration, nameof(Api), ApiDefaultValue); + } - public static string GetAdminConfigValue(IConfiguration configuration) - { - return GetConfigValue(configuration, nameof(Admin), AdminDefaultValue); - } + public static string GetAdminConfigValue(IConfiguration configuration) + { + return GetConfigValue(configuration, nameof(Admin), AdminDefaultValue); + } - public static string GetAdminApiConfigValue(IConfiguration configuration) - { - return GetConfigValue(configuration, nameof(AdminApi), AdminApiDefaultValue); - } + public static string GetAdminApiConfigValue(IConfiguration configuration) + { + return GetConfigValue(configuration, nameof(AdminApi), AdminApiDefaultValue); + } - private static string GetConfigKey(string appName) - { - return $"{ConfigurationName}:{appName}"; - } + private static string GetConfigKey(string appName) + { + return $"{ConfigurationName}:{appName}"; + } - private static string GetConfigValue( - IConfiguration configuration, - string appName, - string defaultValue) - { - return configuration[GetConfigKey(appName)] ?? defaultValue; - } - } -} \ No newline at end of file + private static string GetConfigValue( + IConfiguration configuration, + string appName, + string defaultValue) + { + return configuration[GetConfigKey(appName)] ?? defaultValue; + } + } +} diff --git a/src/EventHub.Domain/Countries/Country.cs b/src/EventHub.Domain/Countries/Country.cs index 1a00f36..1e1ae19 100644 --- a/src/EventHub.Domain/Countries/Country.cs +++ b/src/EventHub.Domain/Countries/Country.cs @@ -4,21 +4,20 @@ using Volo.Abp.Domain.Entities; namespace EventHub.Countries { - public class Country : BasicAggregateRoot - { - public string Name { get; private set; } + public class Country : BasicAggregateRoot + { + public string Name { get; private set; } - private Country() - { + private Country() + { + } - } - - internal Country( - Guid id, - string name) - : base(id) - { - Name = Check.NotNullOrWhiteSpace(name, nameof(name), CountryConsts.MaxNameLength); - } - } -} \ No newline at end of file + internal Country( + Guid id, + string name) + : base(id) + { + Name = Check.NotNullOrWhiteSpace(name, nameof(name), CountryConsts.MaxNameLength); + } + } +} diff --git a/src/EventHub.Domain/Events/Session.cs b/src/EventHub.Domain/Events/Session.cs index c6feb7e..de40c15 100644 --- a/src/EventHub.Domain/Events/Session.cs +++ b/src/EventHub.Domain/Events/Session.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Collections.ObjectModel; +using System.Linq; using Volo.Abp; using Volo.Abp.Domain.Entities; @@ -91,7 +92,12 @@ namespace EventHub.Events internal Session AddSpeaker(Guid userId) { - Speakers.AddIfNotContains(new Speaker(Id, userId)); + if (Speakers.Any(x => x.UserId == userId)) + { + return this; + } + + Speakers.Add(new Speaker(Id, userId)); return this; } diff --git a/src/EventHub.HttpApi/Controllers/Events/EventController.cs b/src/EventHub.HttpApi/Controllers/Events/EventController.cs index b46f2c5..f918f72 100644 --- a/src/EventHub.HttpApi/Controllers/Events/EventController.cs +++ b/src/EventHub.HttpApi/Controllers/Events/EventController.cs @@ -82,6 +82,13 @@ namespace EventHub.Controllers.Events await _eventAppService.UpdateAsync(id, input); } + [HttpPut] + [Route("/publish/{id}")] + public async Task PublishAsync(Guid id) + { + return await _eventAppService.PublishAsync(id); + } + [HttpPost] [Route("{id}/tracks")] public async Task AddTrackAsync(Guid id, AddTractDto input) diff --git a/src/EventHub.Web/Pages/Events/Components/CreateEventArea/CreateEventAreaViewComponent.cs b/src/EventHub.Web/Pages/Events/Components/CreateEventArea/CreateEventAreaViewComponent.cs index a74ffdb..2824760 100644 --- a/src/EventHub.Web/Pages/Events/Components/CreateEventArea/CreateEventAreaViewComponent.cs +++ b/src/EventHub.Web/Pages/Events/Components/CreateEventArea/CreateEventAreaViewComponent.cs @@ -13,9 +13,11 @@ using JetBrains.Annotations; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Rendering; +using Volo.Abp; using Volo.Abp.AspNetCore.Mvc; using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Form; using Volo.Abp.AspNetCore.Mvc.UI.Widgets; +using Volo.Abp.Authorization; using Volo.Abp.Users; namespace EventHub.Web.Pages.Events.Components.CreateEventArea; @@ -62,25 +64,7 @@ public class CreateEventAreaViewComponent : AbpViewComponent EndTime = DateTime.Now.ClearTime().AddDays(2).AddHours(21) }; - ViewData["StepType"] = stepType.ToString(); - switch (stepType) - { - case ProgressStepType.NewEvent: - ViewData["Organizations"] = await GetOrganizationsSelectItemAsync(); - ViewData["Countries"] = await GetCountriesSelectItemAsync(); - ViewData["Languages"] = GetLanguagesSelectItem(); - break; - case ProgressStepType.NewSession: - ViewData["Languages"] = GetLanguagesSelectItem(); - break; - case ProgressStepType.Preview: - ViewData["OrganizationName"] = await GetOrganizationNameAsync(model.OrganizationId); - if (model.CountryId is not null) - { - ViewData["CountryName"] = await GetCountryNameAsync(model.CountryId!.Value); - } - break; - } + await FillViewDataAsync(stepType, model); return View("~/Pages/Events/Components/CreateEventArea/Default.cshtml", model); } @@ -141,6 +125,30 @@ public class CreateEventAreaViewComponent : AbpViewComponent } ).ToList(); } + + private async Task FillViewDataAsync(ProgressStepType stepType, NewEventViewModel model) + { + ViewData["StepType"] = stepType.ToString(); + switch (stepType) + { + case ProgressStepType.NewEvent: + ViewData["Organizations"] = await GetOrganizationsSelectItemAsync(); + ViewData["Countries"] = await GetCountriesSelectItemAsync(); + ViewData["Languages"] = GetLanguagesSelectItem(); + break; + case ProgressStepType.NewSession: + ViewData["Languages"] = GetLanguagesSelectItem(); + break; + case ProgressStepType.Preview: + ViewData["OrganizationName"] = await GetOrganizationNameAsync(model.OrganizationId); + if (model.CountryId is not null) + { + ViewData["CountryName"] = await GetCountryNameAsync(model.CountryId!.Value); + } + + break; + } + } public class NewEventViewModel { diff --git a/src/EventHub.Web/Pages/Events/Components/CreateEventArea/_previewSection.cshtml b/src/EventHub.Web/Pages/Events/Components/CreateEventArea/_previewSection.cshtml index 177e33d..0fd2bca 100644 --- a/src/EventHub.Web/Pages/Events/Components/CreateEventArea/_previewSection.cshtml +++ b/src/EventHub.Web/Pages/Events/Components/CreateEventArea/_previewSection.cshtml @@ -216,7 +216,7 @@ }
- +
diff --git a/src/EventHub.Web/Pages/Events/Components/CreateEventArea/create-event-area.js b/src/EventHub.Web/Pages/Events/Components/CreateEventArea/create-event-area.js index cca2eab..7c17caa 100644 --- a/src/EventHub.Web/Pages/Events/Components/CreateEventArea/create-event-area.js +++ b/src/EventHub.Web/Pages/Events/Components/CreateEventArea/create-event-area.js @@ -33,8 +33,7 @@ FilFileInputChangeEventHandler(); if (eventIdInput.val().length === 36) { - // TODO: Add organization in UppdateEventDto - $('#OrganizationId').prop("disabled", true).removeAttr('name'); + $('#OrganizationId').prop("disabled", true); // Once the Organization is selected, it cannot be changed again. } $("#CreateEventForm").submit(function (e) { @@ -75,9 +74,9 @@ if (eventIdInput.val().length === 36) { abp.notify.success('Updated event'); }else{ - abp.notify.success('Created event as a draft'); + abp.notify.success('Created event as a draft' , '', toastr.options.timeOut = 2500); eventIdInput.val(response.id); - eventUrlCodeInput.val(response.urlCode); + eventUrlCodeInput.val(response.urlCode); } SwitchToTrackCreation() } @@ -101,6 +100,8 @@ EditSessionEventHandler(); DeleteSessionButtonClickEventHandler(); + PublishEventButtonClickEventHandler(); + PrevieousOrNextStepTransitionEventHandler() }; @@ -179,6 +180,7 @@ function DeleteTrackButtonClickEventHandler() { $('.delete-track-button').click(function (e) { + e.preventDefault(); eventApiService.deleteTrack(eventIdInput.val(), this.id).then(function () { abp.notify.success('Successfully deleted'); FillFilter(stepType.NewTrack) @@ -224,6 +226,7 @@ function OpenEditSessionModalClickEventHandler() { $('.edit-session-button').click(function (e) { + e.preventDefault(); var editSessionModal = $('#EditSessionModal'); var clickedSessionId = this.id; @@ -269,6 +272,7 @@ function DeleteSessionButtonClickEventHandler() { $('.delete-session-button').click(function (e) { + e.preventDefault(); var clickedSessionId = this.id; var trackId = $('#' + clickedSessionId).data('track-id'); @@ -280,6 +284,17 @@ }); } + function PublishEventButtonClickEventHandler() { + $('#PublishButton').click(function (e) { + e.preventDefault(); + eventApiService.publish(eventIdInput.val()).then(function (res) { + e.prefe + abp.notify.success('Event Published'); + window.location.replace('https://' + window.location.host + '/events/' + res); + }); + }); + } + function PrevieousOrNextStepTransitionEventHandler() { $('.step-transition').click(function (e) { var clickedButtonId = this.id; diff --git a/src/EventHub.Web/Pages/Events/New.cshtml b/src/EventHub.Web/Pages/Events/New.cshtml index 565d962..445b4a8 100644 --- a/src/EventHub.Web/Pages/Events/New.cshtml +++ b/src/EventHub.Web/Pages/Events/New.cshtml @@ -6,10 +6,7 @@ @model EventHub.Web.Pages.Events.NewPageModel @section scripts { - - - - + } @section styles { diff --git a/src/EventHub.Web/Pages/Events/New.js b/src/EventHub.Web/Pages/Events/New.js deleted file mode 100644 index e69de29..0000000