diff --git a/src/EventHub.Application/Events/EventAppService.cs b/src/EventHub.Application/Events/EventAppService.cs index e82aa9c..0a82507 100644 --- a/src/EventHub.Application/Events/EventAppService.cs +++ b/src/EventHub.Application/Events/EventAppService.cs @@ -262,6 +262,7 @@ namespace EventHub.Events [Authorize] public async Task UpdateAsync(Guid id, UpdateEventDto input) { + // TODO(berkansasmaz): Should it be updated on past events? var @event = await _eventRepository.GetAsync(id); await CheckIfValidOwnerAsync(@event); diff --git a/src/EventHub.Domain.Shared/EventHubErrorCodes.cs b/src/EventHub.Domain.Shared/EventHubErrorCodes.cs index 3d0e7be..fb7a99c 100644 --- a/src/EventHub.Domain.Shared/EventHubErrorCodes.cs +++ b/src/EventHub.Domain.Shared/EventHubErrorCodes.cs @@ -19,7 +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"; public const string SessionTitleAlreadyExist = "EventHub:SessionTitleAlreadyExist"; } diff --git a/src/EventHub.Domain.Shared/Localization/EventHub/en.json b/src/EventHub.Domain.Shared/Localization/EventHub/en.json index c591b04..838a9e5 100644 --- a/src/EventHub.Domain.Shared/Localization/EventHub/en.json +++ b/src/EventHub.Domain.Shared/Localization/EventHub/en.json @@ -158,7 +158,6 @@ "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:DraftEventNotFound": "The draft event not found!", "EventHub:SessionTitleAlreadyExist": "The session {Title} already exists" } } diff --git a/src/EventHub.Domain/Events/Event.cs b/src/EventHub.Domain/Events/Event.cs index 165dfeb..05f27db 100644 --- a/src/EventHub.Domain/Events/Event.cs +++ b/src/EventHub.Domain/Events/Event.cs @@ -243,7 +243,7 @@ namespace EventHub.Events private void CheckIfValidSessionTime(DateTime startTime, DateTime endTime) { - // TODO: This control is already done in Track and even Session. Do you really need this? + // TODO(berkansasmaz): This control is already done in Track and even Session. Do you really need this? if (startTime > endTime) { throw new BusinessException(EventHubErrorCodes.SessionEndTimeCantBeEarlierThanStartTime); diff --git a/src/EventHub.Web/Controllers/WidgetsController.cs b/src/EventHub.Web/Controllers/WidgetsController.cs index 1f8563f..8c4d77a 100644 --- a/src/EventHub.Web/Controllers/WidgetsController.cs +++ b/src/EventHub.Web/Controllers/WidgetsController.cs @@ -1,6 +1,6 @@ using System; using EventHub.Web.Pages.Events.Components.AttendeesArea; -using EventHub.Web.Pages.Events.Components.CreateEventArea; +using EventHub.Web.Pages.Events.Components.CreateOrEditEventArea; using EventHub.Web.Pages.Events.Components.LocationArea; using EventHub.Web.Pages.Events.Components.RegistrationArea; using EventHub.Web.Pages.Organizations.Components.JoinArea; @@ -70,10 +70,10 @@ namespace EventHub.Web.Controllers } [HttpGet] - public IActionResult CreateEventArea(string eventUrlCode, CreateEventAreaViewComponent.ProgressStepType stepType) + public IActionResult CreateOrEditEventArea(string eventUrlCode, CreateOrEditEventAreaViewComponent.ProgressStepType stepType) { return ViewComponent( - typeof(CreateEventAreaViewComponent), + typeof(CreateOrEditEventAreaViewComponent), new { eventUrlCode, diff --git a/src/EventHub.Web/EventHubWebAutoMapperProfile.cs b/src/EventHub.Web/EventHubWebAutoMapperProfile.cs index f036314..813754d 100644 --- a/src/EventHub.Web/EventHubWebAutoMapperProfile.cs +++ b/src/EventHub.Web/EventHubWebAutoMapperProfile.cs @@ -1,7 +1,7 @@ using AutoMapper; using EventHub.Events; using EventHub.Organizations; -using EventHub.Web.Pages.Events.Components.CreateEventArea; +using EventHub.Web.Pages.Events.Components.CreateOrEditEventArea; using EventHub.Web.Pages.Organizations; using Volo.Abp.AutoMapper; using EditPageModel = EventHub.Web.Pages.Events.EditPageModel; @@ -13,13 +13,11 @@ namespace EventHub.Web public EventHubWebAutoMapperProfile() { CreateMap(); - CreateMap() + CreateMap() .Ignore(x => x.CoverImageStreamContent); CreateMap(); CreateMap(); - CreateMap(); - CreateMap(); - CreateMap(); + CreateMap(); } } } diff --git a/src/EventHub.Web/Pages/Events/Components/CreateEventArea/Default.cshtml b/src/EventHub.Web/Pages/Events/Components/CreateEventArea/Default.cshtml deleted file mode 100644 index c56adad..0000000 --- a/src/EventHub.Web/Pages/Events/Components/CreateEventArea/Default.cshtml +++ /dev/null @@ -1,35 +0,0 @@ -@using EventHub.Web.Pages.Events.Components.CreateEventArea -@using Microsoft.AspNetCore.Http -@model EventHub.Web.Pages.Events.Components.CreateEventArea.CreateEventAreaViewComponent.NewEventViewModel - -@{ - if (Model is null) - { - throw new BadHttpRequestException(""); - } - - var eventId = ViewData["EventId"] as Guid?; - var eventUrlCode = ViewData["EventUrlCode"]?.ToString(); - - var result = Enum.TryParse(ViewData["StepType"]!.ToString(), out CreateEventAreaViewComponent.ProgressStepType stepType); - if (!result) - { - throw new BadHttpRequestException(""); - } -} - -
- -
-
- -
-
- -
-
- -
- - - diff --git a/src/EventHub.Web/Pages/Events/Components/CreateEventArea/_progressSection.cshtml b/src/EventHub.Web/Pages/Events/Components/CreateEventArea/_progressSection.cshtml deleted file mode 100644 index 7d99cc8..0000000 --- a/src/EventHub.Web/Pages/Events/Components/CreateEventArea/_progressSection.cshtml +++ /dev/null @@ -1,15 +0,0 @@ -@using EventHub.Web.Pages.Events.Components.CreateEventArea -@model EventHub.Web.Pages.Events.Components.CreateEventArea.CreateEventAreaViewComponent.ProgressStepType - -
-
-
    -
  • 1New Event
  • -
  • 2Add Track
  • -
  • 3Add Session
  • -
-
-
-
-
-
diff --git a/src/EventHub.Web/Pages/Events/Components/CreateEventArea/CreateEventAreaViewComponent.cs b/src/EventHub.Web/Pages/Events/Components/CreateOrEditEventArea/CreateOrEditEventAreaViewComponent.cs similarity index 88% rename from src/EventHub.Web/Pages/Events/Components/CreateEventArea/CreateEventAreaViewComponent.cs rename to src/EventHub.Web/Pages/Events/Components/CreateOrEditEventArea/CreateOrEditEventAreaViewComponent.cs index 2824760..af76d49 100644 --- a/src/EventHub.Web/Pages/Events/Components/CreateEventArea/CreateEventAreaViewComponent.cs +++ b/src/EventHub.Web/Pages/Events/Components/CreateOrEditEventArea/CreateOrEditEventAreaViewComponent.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Collections.ObjectModel; using System.ComponentModel; using System.ComponentModel.DataAnnotations; using System.Globalization; @@ -13,29 +12,27 @@ 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; +namespace EventHub.Web.Pages.Events.Components.CreateOrEditEventArea; [Widget( AutoInitialize = true, - RefreshUrl = "/Widgets/CreateEventArea", - ScriptFiles = new[] { "/Pages/Events/Components/CreateEventArea/create-event-area.js" }, - StyleFiles = new[] { "/Pages/Events/Components/CreateEventArea/create-event-area.css" } + RefreshUrl = "/Widgets/CreateOrEditEventArea", + ScriptFiles = new[] { "/Pages/Events/Components/CreateOrEditEventArea/create-or-edit-event-area.js" }, + StyleFiles = new[] { "/Pages/Events/Components/CreateOrEditEventArea/create-or-edit-event-area.css" } )] -public class CreateEventAreaViewComponent : AbpViewComponent +public class CreateOrEditEventAreaViewComponent : AbpViewComponent { private readonly IEventAppService _eventAppService; private readonly IOrganizationAppService _organizationAppService; private readonly ICurrentUser _currentUser; - public CreateEventAreaViewComponent( + public CreateOrEditEventAreaViewComponent( IEventAppService eventAppService, IOrganizationAppService organizationAppService, ICurrentUser currentUser) @@ -46,8 +43,8 @@ public class CreateEventAreaViewComponent : AbpViewComponent } public async Task InvokeAsync( - string eventUrlCode, - ProgressStepType stepType = ProgressStepType.NewEvent) + string eventUrlCode, + ProgressStepType stepType = ProgressStepType.Event) { NewEventViewModel model = null; if (!eventUrlCode.IsNullOrWhiteSpace()) @@ -66,7 +63,7 @@ public class CreateEventAreaViewComponent : AbpViewComponent await FillViewDataAsync(stepType, model); - return View("~/Pages/Events/Components/CreateEventArea/Default.cshtml", model); + return View("~/Pages/Events/Components/CreateOrEditEventArea/Default.cshtml", model); } private async Task GetOrganizationNameAsync(Guid organizationId) @@ -131,12 +128,12 @@ public class CreateEventAreaViewComponent : AbpViewComponent ViewData["StepType"] = stepType.ToString(); switch (stepType) { - case ProgressStepType.NewEvent: + case ProgressStepType.Event: ViewData["Organizations"] = await GetOrganizationsSelectItemAsync(); ViewData["Countries"] = await GetCountriesSelectItemAsync(); ViewData["Languages"] = GetLanguagesSelectItem(); break; - case ProgressStepType.NewSession: + case ProgressStepType.Session: ViewData["Languages"] = GetLanguagesSelectItem(); break; case ProgressStepType.Preview: @@ -145,7 +142,6 @@ public class CreateEventAreaViewComponent : AbpViewComponent { ViewData["CountryName"] = await GetCountryNameAsync(model.CountryId!.Value); } - break; } } @@ -210,9 +206,9 @@ public class CreateEventAreaViewComponent : AbpViewComponent public enum ProgressStepType : byte { - NewEvent = 0, - NewTrack, - NewSession, + Event = 0, + Track, + Session, Preview } } diff --git a/src/EventHub.Web/Pages/Events/Components/CreateOrEditEventArea/Default.cshtml b/src/EventHub.Web/Pages/Events/Components/CreateOrEditEventArea/Default.cshtml new file mode 100644 index 0000000..7c3134a --- /dev/null +++ b/src/EventHub.Web/Pages/Events/Components/CreateOrEditEventArea/Default.cshtml @@ -0,0 +1,35 @@ +@using EventHub.Web.Pages.Events.Components.CreateOrEditEventArea +@using Microsoft.AspNetCore.Http +@model EventHub.Web.Pages.Events.Components.CreateOrEditEventArea.CreateOrEditEventAreaViewComponent.NewEventViewModel + +@{ + if (Model is null) + { + throw new BadHttpRequestException(""); + } + + var eventId = ViewData["EventId"] as Guid?; + var eventUrlCode = ViewData["EventUrlCode"]?.ToString(); + + var result = Enum.TryParse(ViewData["StepType"]!.ToString(), out CreateOrEditEventAreaViewComponent.ProgressStepType stepType); + if (!result) + { + throw new BadHttpRequestException(""); + } +} + +
+ +
+
+ +
+
+ +
+
+ +
+ + + diff --git a/src/EventHub.Web/Pages/Events/Components/CreateEventArea/_addSessionSection.cshtml b/src/EventHub.Web/Pages/Events/Components/CreateOrEditEventArea/_addSessionSection.cshtml similarity index 95% rename from src/EventHub.Web/Pages/Events/Components/CreateEventArea/_addSessionSection.cshtml rename to src/EventHub.Web/Pages/Events/Components/CreateOrEditEventArea/_addSessionSection.cshtml index 1ade97c..e86e863 100644 --- a/src/EventHub.Web/Pages/Events/Components/CreateEventArea/_addSessionSection.cshtml +++ b/src/EventHub.Web/Pages/Events/Components/CreateOrEditEventArea/_addSessionSection.cshtml @@ -1,12 +1,12 @@ @using EventHub.Web.Pages.Events -@using EventHub.Web.Pages.Events.Components.CreateEventArea @using EventHub.Events +@using EventHub.Web.Pages.Events.Components.CreateOrEditEventArea @using Microsoft.AspNetCore.Http @model List @{ var languages = new List(); - @if (ViewData["StepType"]!.ToString() == CreateEventAreaViewComponent.ProgressStepType.NewSession.ToString()) + @if (ViewData["StepType"]!.ToString() == CreateOrEditEventAreaViewComponent.ProgressStepType.Session.ToString()) { languages = ViewData["Languages"] as List; if (languages is null || !languages.Any()) @@ -24,7 +24,7 @@ } } - + @if (Model is not null) { @@ -96,12 +96,12 @@
- +
diff --git a/src/EventHub.Web/Pages/Events/Components/CreateEventArea/_addTrackSection.cshtml b/src/EventHub.Web/Pages/Events/Components/CreateOrEditEventArea/_addTrackSection.cshtml similarity index 87% rename from src/EventHub.Web/Pages/Events/Components/CreateEventArea/_addTrackSection.cshtml rename to src/EventHub.Web/Pages/Events/Components/CreateOrEditEventArea/_addTrackSection.cshtml index baf348f..dda3496 100644 --- a/src/EventHub.Web/Pages/Events/Components/CreateEventArea/_addTrackSection.cshtml +++ b/src/EventHub.Web/Pages/Events/Components/CreateOrEditEventArea/_addTrackSection.cshtml @@ -1,8 +1,8 @@ -@using EventHub.Web.Pages.Events.Components.CreateEventArea @using EventHub.Events +@using EventHub.Web.Pages.Events.Components.CreateOrEditEventArea @model List - + @if (Model is not null) { @@ -39,11 +39,11 @@ diff --git a/src/EventHub.Web/Pages/Events/Components/CreateEventArea/_modelNullErrorSection.cshtml b/src/EventHub.Web/Pages/Events/Components/CreateOrEditEventArea/_modelNullErrorSection.cshtml similarity index 100% rename from src/EventHub.Web/Pages/Events/Components/CreateEventArea/_modelNullErrorSection.cshtml rename to src/EventHub.Web/Pages/Events/Components/CreateOrEditEventArea/_modelNullErrorSection.cshtml diff --git a/src/EventHub.Web/Pages/Events/Components/CreateEventArea/_newEventSection.cshtml b/src/EventHub.Web/Pages/Events/Components/CreateOrEditEventArea/_newEventSection.cshtml similarity index 95% rename from src/EventHub.Web/Pages/Events/Components/CreateEventArea/_newEventSection.cshtml rename to src/EventHub.Web/Pages/Events/Components/CreateOrEditEventArea/_newEventSection.cshtml index 4704d1c..1306308 100644 --- a/src/EventHub.Web/Pages/Events/Components/CreateEventArea/_newEventSection.cshtml +++ b/src/EventHub.Web/Pages/Events/Components/CreateOrEditEventArea/_newEventSection.cshtml @@ -1,8 +1,8 @@ @using EventHub.Web -@using EventHub.Web.Pages.Events.Components.CreateEventArea +@using EventHub.Web.Pages.Events.Components.CreateOrEditEventArea @using Microsoft.AspNetCore.Http @using Microsoft.Extensions.Options -@model EventHub.Web.Pages.Events.Components.CreateEventArea.CreateEventAreaViewComponent.NewEventViewModel +@model EventHub.Web.Pages.Events.Components.CreateOrEditEventArea.CreateOrEditEventAreaViewComponent.NewEventViewModel @inject IOptions UrlOptions @{ @@ -11,7 +11,7 @@ var languages = new List(); var eventId = ViewData["EventId"] as Guid?; - @if (ViewData["StepType"]!.ToString() == CreateEventAreaViewComponent.ProgressStepType.NewEvent.ToString()) + @if (ViewData["StepType"]!.ToString() == CreateOrEditEventAreaViewComponent.ProgressStepType.Event.ToString()) { organizations = ViewData["Organizations"] as List; if (organizations is null || !organizations.Any()) @@ -33,7 +33,7 @@ } } - + @if (Model is not null) {
diff --git a/src/EventHub.Web/Pages/Events/Components/CreateEventArea/_previewSection.cshtml b/src/EventHub.Web/Pages/Events/Components/CreateOrEditEventArea/_previewSection.cshtml similarity index 93% rename from src/EventHub.Web/Pages/Events/Components/CreateEventArea/_previewSection.cshtml rename to src/EventHub.Web/Pages/Events/Components/CreateOrEditEventArea/_previewSection.cshtml index ce18917..18d55ab 100644 --- a/src/EventHub.Web/Pages/Events/Components/CreateEventArea/_previewSection.cshtml +++ b/src/EventHub.Web/Pages/Events/Components/CreateOrEditEventArea/_previewSection.cshtml @@ -1,16 +1,16 @@ @using EventHub.Web @using EventHub.Web.Pages.Events -@using EventHub.Web.Pages.Events.Components.CreateEventArea +@using EventHub.Web.Pages.Events.Components.CreateOrEditEventArea @using Microsoft.AspNetCore.Http @using Microsoft.Extensions.Options -@model EventHub.Web.Pages.Events.Components.CreateEventArea.CreateEventAreaViewComponent.NewEventViewModel +@model EventHub.Web.Pages.Events.Components.CreateOrEditEventArea.CreateOrEditEventAreaViewComponent.NewEventViewModel @inject IOptions UrlOptions @{ var organizationName = ""; var countryName = ""; Guid? eventId = null; - @if (ViewData["StepType"]!.ToString() == CreateEventAreaViewComponent.ProgressStepType.Preview.ToString()) + @if (ViewData["StepType"]!.ToString() == CreateOrEditEventAreaViewComponent.ProgressStepType.Preview.ToString()) { eventId = ViewData["EventId"] as Guid?; @@ -208,11 +208,11 @@
@if (Model.Tracks.Any() && Model.Tracks.First().Sessions.Any()) { - + } else { - + }
diff --git a/src/EventHub.Web/Pages/Events/Components/CreateOrEditEventArea/_progressSection.cshtml b/src/EventHub.Web/Pages/Events/Components/CreateOrEditEventArea/_progressSection.cshtml new file mode 100644 index 0000000..77c0b3f --- /dev/null +++ b/src/EventHub.Web/Pages/Events/Components/CreateOrEditEventArea/_progressSection.cshtml @@ -0,0 +1,20 @@ +@using EventHub.Web.Pages.Events.Components.CreateOrEditEventArea +@model EventHub.Web.Pages.Events.Components.CreateOrEditEventArea.CreateOrEditEventAreaViewComponent.ProgressStepType + +@{ + var eventId = ViewData["EventId"] as Guid?; + var prefixOfStep = eventId.HasValue ? "Edit" : "New"; +} + +
+
+
    +
  • 1@prefixOfStep Event
  • +
  • 2@prefixOfStep Track
  • +
  • 3@prefixOfStep Session
  • +
+
+
+
+
+
diff --git a/src/EventHub.Web/Pages/Events/Components/CreateEventArea/create-event-area.css b/src/EventHub.Web/Pages/Events/Components/CreateOrEditEventArea/create-or-edit-event-area.css similarity index 100% rename from src/EventHub.Web/Pages/Events/Components/CreateEventArea/create-event-area.css rename to src/EventHub.Web/Pages/Events/Components/CreateOrEditEventArea/create-or-edit-event-area.css diff --git a/src/EventHub.Web/Pages/Events/Components/CreateEventArea/create-event-area.js b/src/EventHub.Web/Pages/Events/Components/CreateOrEditEventArea/create-or-edit-event-area.js similarity index 97% rename from src/EventHub.Web/Pages/Events/Components/CreateEventArea/create-event-area.js rename to src/EventHub.Web/Pages/Events/Components/CreateOrEditEventArea/create-or-edit-event-area.js index 08d1971..3c6ca0b 100644 --- a/src/EventHub.Web/Pages/Events/Components/CreateEventArea/create-event-area.js +++ b/src/EventHub.Web/Pages/Events/Components/CreateOrEditEventArea/create-or-edit-event-area.js @@ -1,13 +1,13 @@ (function () { - abp.widgets.CreateEventArea = function ($wrapper) { + abp.widgets.CreateOrEditEventArea = function ($wrapper) { var l = abp.localization.getResource('EventHub'); toastr.options.timeOut = 500; toastr.options.preventDuplicates = true; var stepType = { - "NewEvent": "NewEvent", - "NewTrack": "NewTrack", - "NewSession": "NewSession", + "Event": "Event", + "Track": "Track", + "Session": "Session", "Preview": "Preview" } @@ -18,7 +18,7 @@ var filter = { eventUrlCode: "", - stepType: stepType.NewEvent + stepType: stepType.Event } var getFilters = function () { @@ -142,7 +142,7 @@ eventApiService.addTrack(eventIdInput.val(), {name: trackName}).then(function () { $('#AddTrackModal').modal('hide'); abp.notify.success('Added the track'); - FillFilter(stepType.NewTrack); + FillFilter(stepType.Track); widgetManager.refresh(); }); }); @@ -181,7 +181,7 @@ eventApiService.updateTrack(eventIdInput.val(), trackId, {name: trackName}).then(function () { $('#EditTrackModal').modal('hide'); abp.notify.success('Updated the track'); - FillFilter(stepType.NewTrack) + FillFilter(stepType.Track) widgetManager.refresh(); }); }); @@ -192,7 +192,7 @@ e.preventDefault(); eventApiService.deleteTrack(eventIdInput.val(), this.id).then(function () { abp.notify.success('Successfully deleted'); - FillFilter(stepType.NewTrack) + FillFilter(stepType.Track) widgetManager.refresh(); }); }); @@ -230,7 +230,7 @@ eventApiService.addSession(eventIdInput.val(), trackId, input).then(function () { $('#AddSessionModal').modal('hide'); abp.notify.success('Added the session'); - FillFilter(stepType.NewSession); + FillFilter(stepType.Session); widgetManager.refresh(); }); }); @@ -276,7 +276,7 @@ eventApiService.updateSession(eventIdInput.val(), editSessionForm.find('#TrackId').val(), editSessionForm.find('#SessionId').val(), input).then(function () { $('#EditSessionModal').modal('hide'); abp.notify.success('Updated the session'); - FillFilter(stepType.NewSession); + FillFilter(stepType.Session); widgetManager.refresh(); }); }); @@ -290,7 +290,7 @@ eventApiService.deleteSession(eventIdInput.val(), trackId, clickedSessionId).then(function () { abp.notify.success('Successfully deleted'); - FillFilter(stepType.NewSession) + FillFilter(stepType.Session) widgetManager.refresh(); }); }); diff --git a/src/EventHub.Web/Pages/Events/Edit.cshtml b/src/EventHub.Web/Pages/Events/Edit.cshtml index 42e6f56..ef7ce64 100644 --- a/src/EventHub.Web/Pages/Events/Edit.cshtml +++ b/src/EventHub.Web/Pages/Events/Edit.cshtml @@ -1,135 +1,19 @@ @page "/event/edit/{url}" -@inject IHtmlLocalizer L -@using EventHub.Localization -@using EventHub.Web -@using Microsoft.AspNetCore.Mvc.Localization -@using Microsoft.Extensions.Options +@using EventHub.Web.Pages.Events.Components.CreateOrEditEventArea @model EventHub.Web.Pages.Events.EditPageModel -@inject IOptions UrlOptions @section scripts { - + } - -
-
-
- -
-
-

Edit Event

-
-
- - -
-
- - -
-
-
-
- - - -
-
-
-
- - - -
-
-
-
- - - -
-
-
-
- - -
-
- -
-

Cover Image

-
-
-
- -
-
-
-
-

For horizontal format 600x300 sized upload images.

- - - -
-
-
-
-
- - -
- -
-
- - - -
-
-
- - -
-
-
- - - -
-
-
- - -
- +@section styles { + +} -
- -
-
-
-
-
-
-
-
- \ No newline at end of file +
+ @await Component.InvokeAsync(typeof(CreateOrEditEventAreaViewComponent), new + { + eventUrlCode = Model.UrlCode, + stepType = CreateOrEditEventAreaViewComponent.ProgressStepType.Event + }) +
diff --git a/src/EventHub.Web/Pages/Events/Edit.cshtml.cs b/src/EventHub.Web/Pages/Events/Edit.cshtml.cs index 2637acb..a08556b 100644 --- a/src/EventHub.Web/Pages/Events/Edit.cshtml.cs +++ b/src/EventHub.Web/Pages/Events/Edit.cshtml.cs @@ -1,202 +1,19 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.ComponentModel.DataAnnotations; -using System.Globalization; -using System.IO; -using System.Linq; -using System.Threading.Tasks; using EventHub.Events; -using EventHub.Organizations; -using EventHub.Web.Helpers; -using JetBrains.Annotations; -using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Mvc; -using Microsoft.AspNetCore.Mvc.Rendering; -using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Form; -using Volo.Abp.Content; -using Volo.Abp.Users; namespace EventHub.Web.Pages.Events { public class EditPageModel : EventHubPageModel { - [BindProperty(SupportsGet = true)] - public new string Url { get; set; } + public string UrlCode { get; set; } - [BindProperty] - public EditEventViewModel Event { get; set; } - - public List Organizations { get; private set; } - public List Countries { get; private set; } - public List Languages { get; private set; } - - private readonly IEventAppService _eventAppService; - private readonly IOrganizationAppService _organizationAppService; - - public EditPageModel( - IEventAppService eventAppService, - IOrganizationAppService organizationAppService) - { - _eventAppService = eventAppService; - _organizationAppService = organizationAppService; - } - - public async Task OnGetAsync() + public EditPageModel() { - var urlCode = EventUrlCodeHelper.GetCodeFromUrl(Url); - var eventDetailDto = await _eventAppService.GetByUrlCodeAsync(urlCode); - - Event = ObjectMapper.Map(eventDetailDto); - await FillOrganizationsAsync(); - await FillCountriesAsync(); - FillLanguages(); } - public async Task OnPostAsync() + public void OnGet(string url) { - try - { - ValidateModel(); - - var updateEventDto = ObjectMapper.Map(Event); - - await using var memoryStream = new MemoryStream(); - if (Event.CoverImageFile != null && Event.CoverImageFile.Length > 0) - { - await Event.CoverImageFile.CopyToAsync(memoryStream); - memoryStream.Position = 0; - - updateEventDto.CoverImageStreamContent = new RemoteStreamContent(memoryStream, fileName: Event.CoverImageFile.FileName, contentType: Event.CoverImageFile.ContentType); - } - - await _eventAppService.UpdateAsync(Event.Id, updateEventDto); - await memoryStream.DisposeAsync(); - - return RedirectToPage("./Detail", new { url = Url }); - } - catch (Exception exception) - { - ShowAlert(exception); - await FillOrganizationsAsync(); - await FillCountriesAsync(); - FillLanguages(); - return Page(); - } - } - - private async Task FillOrganizationsAsync() - { - var result = await _organizationAppService.GetOrganizationsByUserIdAsync(CurrentUser.GetId()); - Organizations = result.Items.Select( - organization => new SelectListItem - { - Value = organization.Id.ToString(), - Text = organization.DisplayName - } - ).ToList(); - - if (Event.OrganizationId != Guid.Empty) - { - Organizations.Single(x => x.Value == Event.OrganizationId.ToString()).Selected = true; - } - } - - private async Task FillCountriesAsync() - { - var result = await _eventAppService.GetCountriesLookupAsync(); - - Countries = result.Select( - country => new SelectListItem - { - Value = country.Id.ToString(), - Text = country.Name - } - ).ToList(); - - if (Event.CountryId.HasValue) - { - Countries.Single(x => x.Value == Event.CountryId.ToString()).Selected = true; - } - } - - 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(); - - if (!string.IsNullOrWhiteSpace(Event.Language)) - { - Languages.Single(x => x.Value == Event.Language).Selected = true; - } - } - - public class EditEventViewModel - { - [HiddenInput] - public Guid Id { get; set; } - - [SelectItems(nameof(Organizations))] - [DisplayName("Organization")] - public Guid OrganizationId { get; set; } - - [Required] - [StringLength(EventConsts.MaxTitleLength, MinimumLength = EventConsts.MinTitleLength)] - public string Title { get; set; } - - [Required] - [DataType(DataType.DateTime)] - public DateTime StartTime { get; set; } = DateTime.Now; - - [Required] - [DataType(DataType.DateTime)] - public DateTime EndTime { get; set; } = DateTime.Now; - - [Required] - [StringLength(EventConsts.MaxDescriptionLength, MinimumLength = EventConsts.MinDescriptionLength)] - [TextArea] - public string Description { get; set; } - - [CanBeNull] - [Display(Name = "Cover Image")] - [DataType(DataType.Upload)] - [MaxFileSize(EventConsts.MaxCoverImageFileSize)] - [AllowedExtensions(new string[] { ".jpg", ".png", ".jpeg" })] - public IFormFile CoverImageFile { get; set; } - - [Required] - 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; } - - [CanBeNull] - [StringLength(EventConsts.MaxCityLength, MinimumLength = EventConsts.MinCityLength)] - public string City { get; set; } - - [SelectItems(nameof(Languages))] - [DisplayName("Language")] - public string Language { get; set; } - - [Range(1, int.MaxValue)] - public int? Capacity { get; set; } + UrlCode = EventUrlCodeHelper.GetCodeFromUrl(url); } } -} \ No newline at end of file +} diff --git a/src/EventHub.Web/Pages/Events/Edit.js b/src/EventHub.Web/Pages/Events/Edit.js deleted file mode 100644 index 75235c3..0000000 --- a/src/EventHub.Web/Pages/Events/Edit.js +++ /dev/null @@ -1,94 +0,0 @@ -$(function () { - var l = abp.localization.getResource('EventHub'); - - var isOnline = $("#Event_IsOnline option:selected").val() - if (isOnline === "True") { - $(".event-link-group").show(); - $(".event-location-group").hide(); - } else { - $(".event-link-group").hide(); - $(".event-location-group").show(); - } - - $('#Event_IsOnline').on('change', '', function () { - var isOnline = $("#Event_IsOnline option:selected").val() - if (isOnline === "True") { - $("#Event_CountryId").attr("required", false); - $("#inputCity").attr("required", false); - $(".event-link-group").show(); - $(".event-location-group").hide(); - } else { - $("#Event_CountryId").attr("required", true); - $("#inputCity").attr("required", true); - $(".event-link-group").hide(); - $(".event-location-group").show(); - } - }); - - var infoArea = document.getElementById('upload-label'); - var fileInput = document.getElementById('Event_CoverImageFile'); - var file; - - if (fileInput !== null) { - fileInput.addEventListener('change', function () { - var showFile = true; - - file = fileInput.files[0]; - - if (file === undefined) { - $('#Event_CoverImageFile').val(''); - $('#imageResult').attr('src', '#'); - infoArea.textContent = 'Choose file' - return; - } - - var permittedExtensions = ["jpg", "jpeg", "png"] - var fileExtension = $(this).val().split('.').pop(); - if (permittedExtensions.indexOf(fileExtension) === -1) { - showFile = false; - abp.message.error(l('EventCoverImageExtensionNotAllowed')) - .then(() => { - $('#Event_CoverImageFile').val(''); - file = null; - }); - } else if (file.size > 1024 * 1024) { - showFile = false; - abp.message.error(l('EventCoverImageSizeExceedMessage')) - .then(() => { - $('#Event_CoverImageFile').val(''); - file = null; - }); - } - - var img = new Image(); - img.onload = function () { - var imageError = true; - var sizes = { - width: this.width, - height: this.height - }; - URL.revokeObjectURL(this.src); - - if (showFile && imageError) { - readURL(file); - } - } - - var objectURL = URL.createObjectURL(file); - img.src = objectURL; - }); - - function readURL(input) { - if (input) { - var reader = new FileReader(); - - reader.onload = function (e) { - $('#imageResult').attr('src', e.target.result); - infoArea.textContent = 'File name: ' + input.name; - } - - reader.readAsDataURL(input); - } - } - } -}); \ No newline at end of file diff --git a/src/EventHub.Web/Pages/Events/New.cshtml b/src/EventHub.Web/Pages/Events/New.cshtml index 445b4a8..24048a6 100644 --- a/src/EventHub.Web/Pages/Events/New.cshtml +++ b/src/EventHub.Web/Pages/Events/New.cshtml @@ -1,7 +1,7 @@ @page "/events/new/{eventUrlCode?}" @inject IHtmlLocalizer L @using EventHub.Localization -@using EventHub.Web.Pages.Events.Components.CreateEventArea +@using EventHub.Web.Pages.Events.Components.CreateOrEditEventArea @using Microsoft.AspNetCore.Mvc.Localization @model EventHub.Web.Pages.Events.NewPageModel @@ -90,10 +90,10 @@ } else { - @await Component.InvokeAsync(typeof(CreateEventAreaViewComponent), new + @await Component.InvokeAsync(typeof(CreateOrEditEventAreaViewComponent), new { eventUrlCode = Model.EventUrlCode, - stepType = CreateEventAreaViewComponent.ProgressStepType.NewEvent + stepType = CreateOrEditEventAreaViewComponent.ProgressStepType.Event }) }
diff --git a/src/EventHub.Web/Pages/Pricing.cshtml b/src/EventHub.Web/Pages/Pricing.cshtml index 135bd4d..949c341 100644 --- a/src/EventHub.Web/Pages/Pricing.cshtml +++ b/src/EventHub.Web/Pages/Pricing.cshtml @@ -8,6 +8,7 @@ } +@* TODO(berkansasmaz): Use real words instead of dummy words.*@

Pricing

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam ut nulla consequat, tempus sapien in,