Browse Source

fix: change signature of AddSessionAsync method

pull/79/head
berkansasmaz 5 years ago
parent
commit
4a22f2ce97
No known key found for this signature in database GPG Key ID: 884D815C3F32BE00
  1. 2
      src/EventHub.Application.Contracts/Events/AddSessionDto.cs
  2. 2
      src/EventHub.Application.Contracts/Events/IEventAppService.cs
  3. 8
      src/EventHub.Application/Events/EventAppService.cs
  4. 6
      src/EventHub.HttpApi/Controllers/Events/EventController.cs
  5. 2
      src/EventHub.Web/Pages/Events/Components/CreateEventArea/_addSessionSection.cshtml
  6. 5
      src/EventHub.Web/Pages/Events/Components/CreateEventArea/create-event-area.js

2
src/EventHub.Application.Contracts/Events/AddSessionDto.cs

@ -6,8 +6,6 @@ namespace EventHub.Events;
public class AddSessionDto
{
public Guid TrackId { get; set; }
[Required]
[StringLength(SessionConsts.MaxTitleLength, MinimumLength = SessionConsts.MinTitleLength)]
public string Title { get; set; }

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

@ -33,7 +33,7 @@ namespace EventHub.Events
Task DeleteTrackAsync(Guid id, Guid trackId);
Task AddSessionAsync(Guid id, AddSessionDto input);
Task AddSessionAsync(Guid id, Guid trackId, AddSessionDto input);
Task UpdateSessionAsync(Guid id, Guid trackId, Guid sessionId, UpdateSessionDto input);

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

@ -79,8 +79,6 @@ namespace EventHub.Events
{
await SaveCoverImageAsync(@event.Id, input.CoverImageStreamContent);
}
@event.Publish(false);
await _eventRepository.InsertAsync(@event);
@ -333,14 +331,14 @@ namespace EventHub.Events
}
[Authorize]
public async Task AddSessionAsync(Guid id, AddSessionDto input)
public async Task AddSessionAsync(Guid id, Guid trackId, AddSessionDto input)
{
await CheckIfValidUserNamesAsync(input.SpeakerUserNames);
var @event = await _eventRepository.GetAsync(id);
await CheckIfValidOwnerAsync(@event);
@event.AddSession(
input.TrackId,
trackId,
GuidGenerator.Create(),
input.Title,
input.Description,
@ -364,9 +362,9 @@ namespace EventHub.Events
trackId,
sessionId,
input.Title,
input.Description,
Clock.Normalize(input.StartTime),
Clock.Normalize(input.EndTime),
input.Description,
input.Language,
await GetUserIdsByUserNamesAsync(input.SpeakerUserNames)
);

6
src/EventHub.HttpApi/Controllers/Events/EventController.cs

@ -111,11 +111,11 @@ namespace EventHub.Controllers.Events
}
[HttpPost]
[Route("{id}/sessions")]
public async Task AddSessionAsync(Guid id, AddSessionDto input)
[Route("{id}/tracks/{trackId}/sessions")]
public async Task AddSessionAsync(Guid id, Guid trackId, AddSessionDto input)
{
input.SpeakerUserNames = input.SpeakerUserNames.Where(x => !x.IsNullOrWhiteSpace()).ToList();
await _eventAppService.AddSessionAsync(id, input);
await _eventAppService.AddSessionAsync(id, trackId, input);
}
[HttpPut]

2
src/EventHub.Web/Pages/Events/Components/CreateEventArea/_addSessionSection.cshtml

@ -118,7 +118,7 @@
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<form id="AddNewSessionForm">
<input type="hidden" id="TrackId" name="TrackId" value="TrackIdPlaceHolder" />
<input disabled type="hidden" id="TrackId" name="TrackId" value="TrackIdPlaceHolder" />
<div class="modal-body profile-content px-5">
<div class="form-floating mb-3">
<input type="text" class="form-control" id="TitleInNewSessionModal" name="Title" placeholder=" " required minLength=@SessionConsts.MinTitleLength maxLength=@SessionConsts.MaxTitleLength />

5
src/EventHub.Web/Pages/Events/Components/CreateEventArea/create-event-area.js

@ -220,11 +220,14 @@
return false;
}
var addSessionModal = $('#AddSessionModal');
var trackId = addSessionModal.find('#TrackId').val();
var userNameList = $('#SpeakersInNewSessionModal').val().split(/[ , ]+/);
userNameList = userNameList.filter(v => v !== '');
var input = $(this).serializeFormToObject();
input.speakerUserNames = userNameList;
eventApiService.addSession(eventIdInput.val(), input).then(function () {
eventApiService.addSession(eventIdInput.val(), trackId, input).then(function () {
$('#AddSessionModal').modal('hide');
abp.notify.success('Added the session');
FillFilter(stepType.NewSession);

Loading…
Cancel
Save