Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added endpoint for download of ALL appointments via ICS-file #912

Closed
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
27b2430
added endpoint for download of ALL appointments via ICS-file
wolfgangroese Apr 7, 2024
b7e095d
Merge branch 'develop' into feature/ARPA-1002-create-endpoint-to-expo…
wolfgangroese Apr 7, 2024
5539371
re-added PackageReference after wrong resolving merge-conflict
wolfgangroese Apr 7, 2024
cf5fc55
Delete __azurite_db_blob__.json
wolfgangroese Apr 7, 2024
d4bd9a6
Delete __azurite_db_blob_extent__.json
wolfgangroese Apr 7, 2024
9393cca
Delete __azurite_db_queue__.json
wolfgangroese Apr 7, 2024
3e6d755
Delete __azurite_db_table__.json
wolfgangroese Apr 7, 2024
6710bc1
Delete __azurite_db_queue_extent__.json
wolfgangroese Apr 7, 2024
f6dc8a5
Merge branch 'develop' into feature/ARPA-1002-create-endpoint-to-expo…
wolfgangroese Apr 30, 2024
e862022
Merge branch 'develop' into feature/ARPA-1002-create-endpoint-to-expo…
wolfgangroese Jun 6, 2024
446c7ff
Merge branch 'develop' into feature/ARPA-1002-create-endpoint-to-expo…
wolfgangroese Jun 21, 2024
567903d
RegisterUser.cs updated (differed from develop-branch)
wolfgangroese Jun 21, 2024
362e994
added ICal.Net package
wolfgangroese Jun 21, 2024
e644e4d
moved logic from controller to service
wolfgangroese Jun 21, 2024
8938b4a
added test to appointment-export
wolfgangroese Jun 21, 2024
a58db9d
remove qodana
wolfgangroese Jun 21, 2024
6a9d12b
outsource method to command (WIP), clean csproj files from ical-pack…
wolfgangroese Jun 23, 2024
5493bf7
finishing export command
wolfgangroese Jun 23, 2024
2b39096
Merge branch 'develop' into feature/ARPA-1002-create-endpoint-to-expo…
wolfgangroese Jun 23, 2024
3a71a34
further corrections and test completion
wolfgangroese Jun 23, 2024
0b59fbc
Merge remote-tracking branch 'origin/feature/ARPA-1002-create-endpoin…
wolfgangroese Jun 23, 2024
277af41
added unittest
wolfgangroese Jun 30, 2024
8b73db8
WIP failing unit-test
wolfgangroese Jul 1, 2024
2e80123
Adapted test
VILLAN3LL3 Jul 1, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
599 changes: 323 additions & 276 deletions Orso.Arpa.Api/Controllers/AppointmentsController.cs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Orso.Arpa.Api/Orso.Arpa.Api.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</PropertyGroup>

<ItemGroup>
<Content Remove="appsettings.Test.json" />
<Content Remove="appsettings.Test.json"/>
</ItemGroup>

<ItemGroup>
Expand Down
15 changes: 11 additions & 4 deletions Orso.Arpa.Api/appsettings.Development.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,12 @@
"internalLogLevel": "Info",
"internalLogFile": "${basedir}/internal-nlog.txt",
"extensions": [
{ "assembly": "NLog.Extensions.Logging" },
{ "assembly": "NLog.Web.AspNetCore" }
{
"assembly": "NLog.Extensions.Logging"
},
{
"assembly": "NLog.Web.AspNetCore"
}
],
"default-wrapper": {
"type": "AsyncWrapper",
Expand Down Expand Up @@ -47,7 +51,7 @@
"EmailConfiguration": {
"From": "dev@arpa.orso.co",
"SmtpServer": "localhost",
"Port": 25,
"Port": 8025,
"Username": "",
"Password": "",
"DefaultSubject": "Message from ARPA"
Expand Down Expand Up @@ -100,7 +104,10 @@
"IpRateLimiting": {
"EnableEndpointRateLimiting": true,
"StackBlockedRequests": true,
"EndpointWhitelist": [ "options:*", "post:/graphql" ],
"EndpointWhitelist": [
"options:*",
"post:/graphql"
],
"HttpStatusCode": 429,
"GeneralRules": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,38 +5,47 @@
using Orso.Arpa.Application.AppointmentParticipationApplication.Model;
using Orso.Arpa.Domain.AppointmentDomain.Enums;

namespace Orso.Arpa.Application.AppointmentApplication.Interfaces
namespace Orso.Arpa.Application.AppointmentApplication.Interfaces;
wolfgangroese marked this conversation as resolved.
Show resolved Hide resolved

public interface IAppointmentService
{
public interface IAppointmentService
{
Task<IEnumerable<AppointmentListDto>> GetAsync(DateTime? date, DateRange range);
Task<IEnumerable<AppointmentListDto>> GetAsync(DateTime? date, DateRange? range);

Task<AppointmentDto> GetByIdAsync(Guid id, bool includeParticipations);

Task<AppointmentDto> CreateAsync(AppointmentCreateDto appointmentCreateDto);

Task ModifyAsync(AppointmentModifyDto appointmentModifyDto);

Task<AppointmentDto> GetByIdAsync(Guid id, bool includeParticipations);
Task RemoveRoomAsync(AppointmentRemoveRoomDto removeRoomDto);

Task<AppointmentDto> CreateAsync(AppointmentCreateDto appointmentCreateDto);
Task AddRoomAsync(AppointmentAddRoomDto addRoomDto);

Task ModifyAsync(AppointmentModifyDto appointmentModifyDto);
Task<AppointmentDto> AddProjectAsync(AppointmentAddProjectDto addProjectDto,
bool includeParticipations);

Task RemoveRoomAsync(AppointmentRemoveRoomDto removeRoomDto);
Task<AppointmentDto> AddSectionAsync(AppointmentAddSectionDto addSectionDto,
bool includeParticipations);

Task AddRoomAsync(AppointmentAddRoomDto addRoomDto);
Task<AppointmentDto> RemoveSectionAsync(AppointmentRemoveSectionDto removeSectionDto,
bool includeParticipations);

Task<AppointmentDto> AddProjectAsync(AppointmentAddProjectDto addProjectDto, bool includeParticipations);
Task<AppointmentDto> RemoveProjectAsync(AppointmentRemoveProjectDto removeProjectDto,
bool includeParticipations);

Task<AppointmentDto> AddSectionAsync(AppointmentAddSectionDto addSectionDto, bool includeParticipations);
Task SetVenueAsync(AppointmentSetVenueDto setVenueDto);

Task<AppointmentDto> RemoveSectionAsync(AppointmentRemoveSectionDto removeSectionDto, bool includeParticipations);
Task<AppointmentDto> SetDatesAsync(AppointmentSetDatesDto setDatesDto);

Task<AppointmentDto> RemoveProjectAsync(AppointmentRemoveProjectDto removeProjectDto, bool includeParticipations);
Task DeleteAsync(Guid id);

Task SetVenueAsync(AppointmentSetVenueDto setVenueDto);
Task SetParticipationResultAsync(AppointmentParticipationSetResultDto setParticipationResult);

Task<AppointmentDto> SetDatesAsync(AppointmentSetDatesDto setDatesDto);
Task SetParticipationPredictionAsync(
AppointmentParticipationSetPredictionDto setParticipationPrediction);

Task DeleteAsync(Guid id);
Task SendAppointmentChangedNotificationAsync(
SendAppointmentChangedNotificationDto sendAppointmentChangedNotificationDto);

Task SetParticipationResultAsync(AppointmentParticipationSetResultDto setParticipationResult);
Task SetParticipationPredictionAsync(AppointmentParticipationSetPredictionDto setParticipationPrediction);
Task SendAppointmentChangedNotificationAsync(SendAppointmentChangedNotificationDto sendAppointmentChangedNotificationDto);
}
Task<string> ExportAppointmentsToIcsAsync();
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,139 +18,171 @@
using Orso.Arpa.Domain.SectionDomain.Model;
using Orso.Arpa.Domain.SectionDomain.Queries;

namespace Orso.Arpa.Application.AppointmentApplication.Services
namespace Orso.Arpa.Application.AppointmentApplication.Services;

public class AppointmentService : BaseService<
AppointmentDto,
Appointment,
AppointmentCreateDto,
CreateAppointment.Command,
AppointmentModifyDto,
AppointmentModifyBodyDto,
ModifyAppointment.Command>, IAppointmentService
{
public class AppointmentService : BaseService<
AppointmentDto,
Appointment,
AppointmentCreateDto,
CreateAppointment.Command,
AppointmentModifyDto,
AppointmentModifyBodyDto,
ModifyAppointment.Command>, IAppointmentService
{
public AppointmentService(IMediator mediator, IMapper mapper) : base(mediator, mapper)
{
}
public AppointmentService(IMediator mediator, IMapper mapper) : base(mediator, mapper)
{
}

public async Task<AppointmentDto> AddProjectAsync(AppointmentAddProjectDto addProjectDto, bool includeParticipations)
{
AddProjectToAppointment.Command command = _mapper.Map<AddProjectToAppointment.Command>(addProjectDto);
await _mediator.Send(command);
return await GetByIdAsync(addProjectDto.Id, includeParticipations);
}
public async Task<AppointmentDto> AddProjectAsync(AppointmentAddProjectDto addProjectDto,
bool includeParticipations)
{
AddProjectToAppointment.Command command =
_mapper.Map<AddProjectToAppointment.Command>(addProjectDto);
await _mediator.Send(command);
return await GetByIdAsync(addProjectDto.Id, includeParticipations);
}

public async Task<AppointmentDto> AddSectionAsync(AppointmentAddSectionDto addSectionDto, bool includeParticipations)
{
AddSectionToAppointment.Command command = _mapper.Map<AddSectionToAppointment.Command>(addSectionDto);
await _mediator.Send(command);
return await GetByIdAsync(addSectionDto.Id, includeParticipations);
}
public async Task<AppointmentDto> AddSectionAsync(AppointmentAddSectionDto addSectionDto,
bool includeParticipations)
{
AddSectionToAppointment.Command command =
_mapper.Map<AddSectionToAppointment.Command>(addSectionDto);
await _mediator.Send(command);
return await GetByIdAsync(addSectionDto.Id, includeParticipations);
}

public async Task AddRoomAsync(AppointmentAddRoomDto addRoomDto)
{
AddRoomToAppointment.Command command = _mapper.Map<AddRoomToAppointment.Command>(addRoomDto);
await _mediator.Send(command);
}
public async Task AddRoomAsync(AppointmentAddRoomDto addRoomDto)
{
AddRoomToAppointment.Command
command = _mapper.Map<AddRoomToAppointment.Command>(addRoomDto);
await _mediator.Send(command);
}

public async Task<IEnumerable<AppointmentListDto>> GetAsync(DateTime? date, DateRange range)
public async Task<IEnumerable<AppointmentListDto>> GetAsync(DateTime? date, DateRange? range)
{
if (range.HasValue)
{
date ??= DateTime.Today;
DateTime rangeStartTime = DateHelper.GetStartTime(date.Value, range.Value);
DateTime rangeEndTime = DateHelper.GetEndTime(date.Value, range.Value);

DateTime rangeStartTime = DateHelper.GetStartTime(date.Value, range);
DateTime rangeEndTime = DateHelper.GetEndTime(date.Value, range);
IQueryable<Appointment> entities = await _mediator.Send(new List.Query<Appointment>(
a => (a.EndTime <= rangeEndTime && a.EndTime >= rangeStartTime) ||
(a.EndTime > rangeEndTime && a.StartTime <= rangeEndTime),
asSplitQuery: true));

return _mapper.ProjectTo<AppointmentListDto>(entities);
}
else
{
IQueryable<Appointment> entities = await _mediator.Send(new List.Query<Appointment>(
predicate: a =>
(a.EndTime <= rangeEndTime && a.EndTime >= rangeStartTime)
|| (a.EndTime > rangeEndTime && a.StartTime <= rangeEndTime),
asSplitQuery: true));

return [.. _mapper.ProjectTo<AppointmentListDto>(entities)];
return _mapper.ProjectTo<AppointmentListDto>(entities);
}
}

public async Task<AppointmentDto> GetByIdAsync(Guid id, bool includeParticipations)
public async Task<AppointmentDto> GetByIdAsync(Guid id, bool includeParticipations)
{
Appointment appointment = await _mediator.Send(new Details.Query<Appointment>(id));
AppointmentDto dto = _mapper.Map<AppointmentDto>(appointment);
if (includeParticipations)
{
Appointment appointment = await _mediator.Send(new Details.Query<Appointment>(id));
AppointmentDto dto = _mapper.Map<AppointmentDto>(appointment);
if (includeParticipations)
{
var treeQuery = new ListFlattenedSectionTree.Query();
IEnumerable<ITree<Section>> flattenedTree = await _mediator.Send(treeQuery);
await AddParticipationsAsync(dto, appointment, flattenedTree);
}
return dto;
var treeQuery = new ListFlattenedSectionTree.Query();
IEnumerable<ITree<Section>> flattenedTree = await _mediator.Send(treeQuery);
await AddParticipationsAsync(dto, appointment, flattenedTree);
}

private async Task AddParticipationsAsync(
AppointmentDto dto,
Appointment appointment,
IEnumerable<ITree<Section>> flattenedTree)
{
var query = new ListParticipationsForAppointment.Query
{
Appointment = appointment,
SectionTree = flattenedTree,
};
return dto;
}

IEnumerable<ListParticipationsForAppointment.PersonGrouping> personGrouping = await _mediator.Send(query);
public async Task<AppointmentDto> RemoveProjectAsync(
AppointmentRemoveProjectDto removeProjectDto, bool includeParticipations)
{
RemoveProjectFromAppointment.Command command =
_mapper.Map<RemoveProjectFromAppointment.Command>(removeProjectDto);
await _mediator.Send(command);
return await GetByIdAsync(removeProjectDto.Id, includeParticipations);
}

dto.Participations = _mapper.Map<IList<AppointmentParticipationListItemDto>>(personGrouping);
}
public async Task<AppointmentDto> RemoveSectionAsync(
AppointmentRemoveSectionDto removeSectionDto, bool includeParticipations)
{
RemoveSectionFromAppointment.Command command =
_mapper.Map<RemoveSectionFromAppointment.Command>(removeSectionDto);
await _mediator.Send(command);
return await GetByIdAsync(removeSectionDto.Id, includeParticipations);
}

public async Task<AppointmentDto> RemoveProjectAsync(AppointmentRemoveProjectDto removeProjectDto, bool includeParticipations)
{
RemoveProjectFromAppointment.Command command = _mapper.Map<RemoveProjectFromAppointment.Command>(removeProjectDto);
await _mediator.Send(command);
return await GetByIdAsync(removeProjectDto.Id, includeParticipations);
}
public async Task RemoveRoomAsync(AppointmentRemoveRoomDto removeRoomDto)
{
RemoveRoomFromAppointment.Command command =
_mapper.Map<RemoveRoomFromAppointment.Command>(removeRoomDto);
await _mediator.Send(command);
}

public async Task<AppointmentDto> RemoveSectionAsync(AppointmentRemoveSectionDto removeSectionDto, bool includeParticipations)
{
RemoveSectionFromAppointment.Command command = _mapper.Map<RemoveSectionFromAppointment.Command>(removeSectionDto);
await _mediator.Send(command);
return await GetByIdAsync(removeSectionDto.Id, includeParticipations);
}
public async Task<AppointmentDto> SetDatesAsync(AppointmentSetDatesDto setDatesDto)
{
SetDates.Command command = _mapper.Map<SetDates.Command>(setDatesDto);
Appointment appointment = await _mediator.Send(command);
AppointmentDto dto = _mapper.Map<AppointmentDto>(appointment);
var treeQuery = new ListFlattenedSectionTree.Query();
IEnumerable<ITree<Section>> flattenedTree = await _mediator.Send(treeQuery);
await AddParticipationsAsync(dto, appointment, flattenedTree);
return dto;
}

public async Task RemoveRoomAsync(AppointmentRemoveRoomDto removeRoomDto)
{
RemoveRoomFromAppointment.Command command = _mapper.Map<RemoveRoomFromAppointment.Command>(removeRoomDto);
await _mediator.Send(command);
}
public async Task SetVenueAsync(AppointmentSetVenueDto setVenueDto)
{
SetVenue.Command command = _mapper.Map<SetVenue.Command>(setVenueDto);
await _mediator.Send(command);
}

public async Task<AppointmentDto> SetDatesAsync(AppointmentSetDatesDto setDatesDto)
{
SetDates.Command command = _mapper.Map<SetDates.Command>(setDatesDto);
Appointment appointment = await _mediator.Send(command);
AppointmentDto dto = _mapper.Map<AppointmentDto>(appointment);
var treeQuery = new ListFlattenedSectionTree.Query();
IEnumerable<ITree<Section>> flattenedTree = await _mediator.Send(treeQuery);
await AddParticipationsAsync(dto, appointment, flattenedTree);
return dto;
}
public async Task SetParticipationResultAsync(
AppointmentParticipationSetResultDto setParticipationResult)
{
SetAppointmentParticipationResult.Command command =
_mapper.Map<SetAppointmentParticipationResult.Command>(setParticipationResult);
await _mediator.Send(command);
}

public async Task SetVenueAsync(AppointmentSetVenueDto setVenueDto)
{
SetVenue.Command command = _mapper.Map<SetVenue.Command>(setVenueDto);
await _mediator.Send(command);
}
public async Task SetParticipationPredictionAsync(
AppointmentParticipationSetPredictionDto setParticipationPrediction)
{
SetAppointmentParticipationPrediction.Command command =
_mapper.Map<SetAppointmentParticipationPrediction.Command>(setParticipationPrediction);
await _mediator.Send(command);
}

public async Task SetParticipationResultAsync(AppointmentParticipationSetResultDto setParticipationResult)
{
SetAppointmentParticipationResult.Command command = _mapper.Map<SetAppointmentParticipationResult.Command>(setParticipationResult);
await _mediator.Send(command);
}
public async Task SendAppointmentChangedNotificationAsync(
SendAppointmentChangedNotificationDto sendAppointmentChangedNotificationDto)
{
SendAppointmentChangedNotification.Command command =
_mapper.Map<SendAppointmentChangedNotification.Command>(
sendAppointmentChangedNotificationDto);
await _mediator.Send(command);
}

public async Task SetParticipationPredictionAsync(AppointmentParticipationSetPredictionDto setParticipationPrediction)
private async Task AddParticipationsAsync(
AppointmentDto dto,
Appointment appointment,
IEnumerable<ITree<Section>> flattenedTree)
{
var query = new ListParticipationsForAppointment.Query
{
SetAppointmentParticipationPrediction.Command command = _mapper.Map<SetAppointmentParticipationPrediction.Command>(setParticipationPrediction);
await _mediator.Send(command);
}
Appointment = appointment, SectionTree = flattenedTree
};

public async Task SendAppointmentChangedNotificationAsync(SendAppointmentChangedNotificationDto sendAppointmentChangedNotificationDto)
{
SendAppointmentChangedNotification.Command command = _mapper.Map<SendAppointmentChangedNotification.Command>(sendAppointmentChangedNotificationDto);
await _mediator.Send(command);
}
IEnumerable<ListParticipationsForAppointment.PersonGrouping> personGrouping =
await _mediator.Send(query);

dto.Participations =
_mapper.Map<IList<AppointmentParticipationListItemDto>>(personGrouping);
}

public async Task<string> ExportAppointmentsToIcsAsync()
wolfgangroese marked this conversation as resolved.
Show resolved Hide resolved
{
var command = new ExportAppointmentsToIcs.Command();
return await _mediator.Send(command);
}
}
3 changes: 2 additions & 1 deletion Orso.Arpa.Application/Orso.Arpa.Application.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@
<ProjectReference Include="..\Orso.Arpa.Infrastructure\Orso.Arpa.Infrastructure.csproj" />
<ProjectReference Include="..\Orso.Arpa.Persistence\Orso.Arpa.Persistence.csproj" />
</ItemGroup>
</Project>

</Project>
Loading
Loading