From bd8f31b9b209e8de7a284363bc51568bf1553a2b Mon Sep 17 00:00:00 2001 From: berkansasmaz Date: Tue, 14 Dec 2021 18:11:29 +0300 Subject: [PATCH] feat: add session --- .../Events/AddSessionDto.cs | 6 +- .../Events/TrackDto.cs | 2 +- .../Users/IUserAppService.cs | 5 +- .../Users/UserInListDto.cs | 6 + .../EventHubApplicationAutoMapperProfile.cs | 2 + .../Events/EventAppService.cs | 18 +- .../Users/UserAppService.cs | 23 ++- src/EventHub.Domain/Events/Session.cs | 13 +- src/EventHub.Domain/Events/Track.cs | 2 +- .../Users/UserWithoutDetails.cs | 10 + .../Controllers/Users/UserController.cs | 10 +- .../wwwroot/themes/eventhub/style.css | 6 +- .../CreateEventAreaViewComponent.cs | 11 +- .../CreateEventArea/_addSessionSection.cshtml | 190 ++++++++++++++---- .../CreateEventArea/_addTrackSection.cshtml | 7 +- .../_modelNullErrorSection.cshtml | 4 +- .../CreateEventArea/create-event-area.css | 0 .../CreateEventArea/create-event-area.js | 64 ++++++ src/EventHub.Web/wwwroot/global-styles.css | 10 +- 19 files changed, 323 insertions(+), 66 deletions(-) create mode 100644 src/EventHub.Application.Contracts/Users/UserInListDto.cs create mode 100644 src/EventHub.Domain/Users/UserWithoutDetails.cs create mode 100644 src/EventHub.Web/Pages/Events/Components/CreateEventArea/create-event-area.css diff --git a/src/EventHub.Application.Contracts/Events/AddSessionDto.cs b/src/EventHub.Application.Contracts/Events/AddSessionDto.cs index 6a8d3ac..d91e20d 100644 --- a/src/EventHub.Application.Contracts/Events/AddSessionDto.cs +++ b/src/EventHub.Application.Contracts/Events/AddSessionDto.cs @@ -11,8 +11,12 @@ public class AddSessionDto [StringLength(SessionConsts.MaxTitleLength, MinimumLength = SessionConsts.MinTitleLength)] public string Title { get; set; } + [Required] + [DataType(DataType.DateTime)] public DateTime StartTime { get; set; } - + + [Required] + [DataType(DataType.DateTime)] public DateTime EndTime { get; set; } [Required] diff --git a/src/EventHub.Application.Contracts/Events/TrackDto.cs b/src/EventHub.Application.Contracts/Events/TrackDto.cs index 2a555b9..5b39693 100644 --- a/src/EventHub.Application.Contracts/Events/TrackDto.cs +++ b/src/EventHub.Application.Contracts/Events/TrackDto.cs @@ -7,7 +7,7 @@ namespace EventHub.Events; public class TrackDto : EntityDto { public string Name { get; set; } - + public List Sessions { get; set; } public TrackDto() diff --git a/src/EventHub.Application.Contracts/Users/IUserAppService.cs b/src/EventHub.Application.Contracts/Users/IUserAppService.cs index 6b71d6f..951b8f6 100644 --- a/src/EventHub.Application.Contracts/Users/IUserAppService.cs +++ b/src/EventHub.Application.Contracts/Users/IUserAppService.cs @@ -1,3 +1,4 @@ +using System.Collections.Generic; using System.Threading.Tasks; using EventHub.Members; using Volo.Abp.Application.Services; @@ -7,5 +8,7 @@ namespace EventHub.Users public interface IUserAppService : IApplicationService { Task FindByUserNameAsync(string username); + + Task> GetListByUserName(string username); } -} \ No newline at end of file +} diff --git a/src/EventHub.Application.Contracts/Users/UserInListDto.cs b/src/EventHub.Application.Contracts/Users/UserInListDto.cs new file mode 100644 index 0000000..52af0a8 --- /dev/null +++ b/src/EventHub.Application.Contracts/Users/UserInListDto.cs @@ -0,0 +1,6 @@ +namespace EventHub.Users; + +public class UserInListDto +{ + public string UserName { get; set; } +} diff --git a/src/EventHub.Application/EventHubApplicationAutoMapperProfile.cs b/src/EventHub.Application/EventHubApplicationAutoMapperProfile.cs index 4740b6b..0e04144 100644 --- a/src/EventHub.Application/EventHubApplicationAutoMapperProfile.cs +++ b/src/EventHub.Application/EventHubApplicationAutoMapperProfile.cs @@ -49,6 +49,8 @@ namespace EventHub CreateMap(); CreateMap(); + + CreateMap(); } } } diff --git a/src/EventHub.Application/Events/EventAppService.cs b/src/EventHub.Application/Events/EventAppService.cs index a2dc966..01f669d 100644 --- a/src/EventHub.Application/Events/EventAppService.cs +++ b/src/EventHub.Application/Events/EventAppService.cs @@ -252,12 +252,12 @@ namespace EventHub.Events @event.Language = input.Language; @event.SetTime(input.StartTime, input.EndTime); await _eventManager.SetCapacityAsync(@event, input.Capacity); - + if (input.CoverImageStreamContent != null && input.CoverImageStreamContent.ContentLength > 0) { await SaveCoverImageAsync(@event.Id, input.CoverImageStreamContent); } - + await _eventRepository.UpdateAsync(@event); } @@ -266,28 +266,30 @@ namespace EventHub.Events { var @event = await _eventRepository.GetAsync(id, true); await CheckOwnerControlAsync(@event); - + @event.AddTract( GuidGenerator.Create(), input.Name ); - + await _eventRepository.UpdateAsync(@event); } + [Authorize] public async Task UpdateTrackAsync(Guid id, Guid trackId, UpdateTrackDto input) { var @event = await _eventRepository.GetAsync(id, true); await CheckOwnerControlAsync(@event); - + @event.UpdateTrack( trackId, input.Name ); - + await _eventRepository.UpdateAsync(@event); } + [Authorize] public async Task DeleteTrackAsync(Guid id, Guid trackId) { var @event = await _eventRepository.GetAsync(id, true); @@ -332,7 +334,7 @@ namespace EventHub.Events await _eventBlobContainer.SaveAsync(blobName, streamContent.GetStream(), overrideExisting: true); } - + private async Task CheckOwnerControlAsync(Event @event) { var organization = await _organizationRepository.GetAsync(@event.OrganizationId); @@ -345,7 +347,7 @@ namespace EventHub.Events ); } } - + private List GetEventInListDtoFromEventAndOrganizationTupleList(List<(Event @event, Organization organization)> items) { var now = Clock.Now; diff --git a/src/EventHub.Application/Users/UserAppService.cs b/src/EventHub.Application/Users/UserAppService.cs index 42ed495..e7b095b 100644 --- a/src/EventHub.Application/Users/UserAppService.cs +++ b/src/EventHub.Application/Users/UserAppService.cs @@ -1,7 +1,8 @@ -using System; +using System.Collections.Generic; +using System.Linq; using System.Threading.Tasks; using EventHub.Members; -using Volo.Abp.Domain.Repositories; +using Microsoft.AspNetCore.Authorization; using Volo.Abp.Identity; namespace EventHub.Users @@ -21,5 +22,21 @@ namespace EventHub.Users return ObjectMapper.Map(user); } + + [Authorize] + public async Task> GetListByUserName(string username) + { + var userQueryable = await _userRepository.GetQueryableAsync(); + + var query = userQueryable + .Where(u => u.UserName.Contains(username)) + .Select(x => new UserWithoutDetails + { + Id = x.Id, + UserName = x.UserName + }).Take(10); + + return ObjectMapper.Map, List>(await AsyncExecuter.ToListAsync(query)); + } } -} \ No newline at end of file +} diff --git a/src/EventHub.Domain/Events/Session.cs b/src/EventHub.Domain/Events/Session.cs index 2b6f539..290b4fb 100644 --- a/src/EventHub.Domain/Events/Session.cs +++ b/src/EventHub.Domain/Events/Session.cs @@ -33,13 +33,15 @@ namespace EventHub.Events string title, DateTime startTime, DateTime endTime, - string description) + string description, + string language) : base(id) { TrackId = trackId; SetTitle(title); SetDescription(description); SetTime(startTime, endTime); + SetLanguage(language); Speakers = new Collection(); } @@ -66,5 +68,12 @@ namespace EventHub.Events EndTime = endTime; return this; } + + internal Session SetLanguage(string language) + { + Language = Check.NotNullOrWhiteSpace(language, nameof(language), SessionConsts.MaxLanguageLength); + + return this; + } } -} \ No newline at end of file +} diff --git a/src/EventHub.Domain/Events/Track.cs b/src/EventHub.Domain/Events/Track.cs index 408efb9..bbe90b5 100644 --- a/src/EventHub.Domain/Events/Track.cs +++ b/src/EventHub.Domain/Events/Track.cs @@ -58,7 +58,7 @@ namespace EventHub.Events } } - Sessions.Add(new Session(sessionId, Id, title, startTime, endTime, description)); + Sessions.Add(new Session(sessionId, Id, title, startTime, endTime, description, language)); return this; } diff --git a/src/EventHub.Domain/Users/UserWithoutDetails.cs b/src/EventHub.Domain/Users/UserWithoutDetails.cs new file mode 100644 index 0000000..b02395f --- /dev/null +++ b/src/EventHub.Domain/Users/UserWithoutDetails.cs @@ -0,0 +1,10 @@ +using System; + +namespace EventHub.Users; + +public class UserWithoutDetails +{ + public Guid Id { get; set; } + + public string UserName { get; set; } +} diff --git a/src/EventHub.HttpApi/Controllers/Users/UserController.cs b/src/EventHub.HttpApi/Controllers/Users/UserController.cs index 0ac1a38..9147c3a 100644 --- a/src/EventHub.HttpApi/Controllers/Users/UserController.cs +++ b/src/EventHub.HttpApi/Controllers/Users/UserController.cs @@ -1,3 +1,4 @@ +using System.Collections.Generic; using System.Threading.Tasks; using EventHub.Members; using EventHub.Users; @@ -10,7 +11,7 @@ namespace EventHub.Controllers.Users [RemoteService(Name = EventHubRemoteServiceConsts.RemoteServiceName)] [Area("eventhubm")] [ControllerName("User")] - [Route("/api/eventhub/user")] + [Route("/api/eventhub/users")] public class UserController : EventHubController, IUserAppService { private readonly IUserAppService _userAppService; @@ -26,5 +27,12 @@ namespace EventHub.Controllers.Users { return await _userAppService.FindByUserNameAsync(username); } + + [HttpGet] + [Route("contains/{username}")] + public async Task> GetListByUserName(string username) + { + return await _userAppService.GetListByUserName(username); + } } } diff --git a/src/EventHub.Web.Theme/wwwroot/themes/eventhub/style.css b/src/EventHub.Web.Theme/wwwroot/themes/eventhub/style.css index bc1f35f..b931deb 100644 --- a/src/EventHub.Web.Theme/wwwroot/themes/eventhub/style.css +++ b/src/EventHub.Web.Theme/wwwroot/themes/eventhub/style.css @@ -57,6 +57,10 @@ p { word-wrap: break-word; } +textarea { + height: 90px!important; +} + /*NAVBAR*/ .navbar { box-shadow: 0 5px 10px rgba(0, 4, 74, 0.05) !important; @@ -1092,4 +1096,4 @@ div.checkbox.switcher label input:checked + span small, div.radio.switcher label } } -/*This area was made to be able to navigate between pages. It should be removed from the project*/ \ No newline at end of file +/*This area was made to be able to navigate between pages. It should be removed from the project*/ diff --git a/src/EventHub.Web/Pages/Events/Components/CreateEventArea/CreateEventAreaViewComponent.cs b/src/EventHub.Web/Pages/Events/Components/CreateEventArea/CreateEventAreaViewComponent.cs index 337273b..a7f5b8e 100644 --- a/src/EventHub.Web/Pages/Events/Components/CreateEventArea/CreateEventAreaViewComponent.cs +++ b/src/EventHub.Web/Pages/Events/Components/CreateEventArea/CreateEventAreaViewComponent.cs @@ -23,7 +23,8 @@ namespace EventHub.Web.Pages.Events.Components.CreateEventArea; [Widget( AutoInitialize = true, RefreshUrl = "/Widgets/CreateEventArea", - ScriptFiles = new[] { "/Pages/Events/Components/CreateEventArea/create-event-area.js" } + ScriptFiles = new[] { "/Pages/Events/Components/CreateEventArea/create-event-area.js" }, + StyleFiles = new[] { "/Pages/Events/Components/CreateEventArea/create-event-area.css" } )] public class CreateEventAreaViewComponent : AbpViewComponent { @@ -54,13 +55,13 @@ public class CreateEventAreaViewComponent : AbpViewComponent ViewData["EventId"] = @event.Id; ViewData["EventUrlCode"] = @event.UrlCode; } - + model ??= new NewEventViewModel { StartTime = DateTime.Now.ClearTime().AddDays(1).AddHours(19), EndTime = DateTime.Now.ClearTime().AddDays(1).AddHours(21) }; - + ViewData["StepType"] = stepType.ToString(); ViewData["Organizations"] = await GetOrganizationsSelectItemAsync(); ViewData["Countries"] = await GetCountriesSelectItemAsync(); @@ -81,7 +82,7 @@ public class CreateEventAreaViewComponent : AbpViewComponent } ).ToList(); } - + private async Task> GetCountriesSelectItemAsync() { var result = await _eventAppService.GetCountriesLookupAsync(); @@ -169,7 +170,7 @@ public class CreateEventAreaViewComponent : AbpViewComponent Tracks = new List(); } } - + public enum ProgressStepType : byte { NewEvent = 0, diff --git a/src/EventHub.Web/Pages/Events/Components/CreateEventArea/_addSessionSection.cshtml b/src/EventHub.Web/Pages/Events/Components/CreateEventArea/_addSessionSection.cshtml index 86ac781..62b3eb5 100644 --- a/src/EventHub.Web/Pages/Events/Components/CreateEventArea/_addSessionSection.cshtml +++ b/src/EventHub.Web/Pages/Events/Components/CreateEventArea/_addSessionSection.cshtml @@ -1,50 +1,73 @@ @using EventHub.Web.Pages.Events @using EventHub.Web.Pages.Events.Components.CreateEventArea +@using EventHub.Events +@using Microsoft.AspNetCore.Http @model List - +@{ + var languages = ViewData["Languages"] as IList; + if (languages is null || !languages.Any()) + { + throw new BadHttpRequestException("There is no language"); + } + languages = languages.Select(l => + { + if (l.Value == "en") + { + l.Selected = true; + } + return l; + }).ToList(); +} + + @if (Model is not null) {
-
-
-
-

Add Session

- - +
+
+
+

Add Session

+
+ @foreach (var track in Model) - { - - } - + { + + } + - - @foreach (var track in Model) - { - + @foreach (var track in Model) + { + - } - + + } +
@track.Name
+ @track.Name.TruncateWithPostfix(20) +
- @foreach (var session in track.Sessions) - { -
- @session.Title - @EventDateHelper.GetTimeRangeText(TimeOnly.FromDateTime(session.StartTime), TimeOnly.FromDateTime(session.EndTime)) | @session.Language - @foreach (var speaker in session.Speakers) - { - @speaker.UserName - } - - Edit +
+ @foreach (var session in track.Sessions) + { +
+ @session.Title + @EventDateHelper.GetTimeRangeText(TimeOnly.FromDateTime(session.StartTime), TimeOnly.FromDateTime(session.EndTime)) | @session.Language + @foreach (var speaker in session.Speakers) + { + @speaker.UserName + } + + Edit + +
+ } + - } - -
@@ -52,7 +75,10 @@ -}else + + + + + + +} +else { - + } diff --git a/src/EventHub.Web/Pages/Events/Components/CreateEventArea/_addTrackSection.cshtml b/src/EventHub.Web/Pages/Events/Components/CreateEventArea/_addTrackSection.cshtml index 6b894ef..f7eef3d 100644 --- a/src/EventHub.Web/Pages/Events/Components/CreateEventArea/_addTrackSection.cshtml +++ b/src/EventHub.Web/Pages/Events/Components/CreateEventArea/_addTrackSection.cshtml @@ -1,4 +1,5 @@ @using EventHub.Web.Pages.Events.Components.CreateEventArea +@using EventHub.Events @model List @@ -15,7 +16,7 @@ {
- @track.Name + @track.Name Edit @@ -61,7 +62,7 @@
@@ -88,7 +89,7 @@