feat: replace manual event search in favor of dto builders

This commit is contained in:
2025-06-01 23:55:43 +02:00
parent 07128948b0
commit 42fd94e5ac
6 changed files with 118 additions and 94 deletions

View File

@@ -34,16 +34,30 @@ public static class EventMapping
public static EventSummaryDto ToEventSummaryDto(this Event myEvent)
{
List<SkillSummaryDto> ssdto = new List<SkillSummaryDto>();
List<EventRegistrationDto> erdto = new List<EventRegistrationDto>();
foreach (EventSkill es in myEvent.EventSkills)
{
ssdto.Add(es.ToSkillSummaryDto());
}
foreach (EventRegistration er in myEvent.EventRegistrations)
{
erdto.Add(er.ToEventRegistrationDto());
}
return new EventSummaryDto {
EventId = myEvent.EventId,
Organisation = myEvent.Organisation!.Name,
OrganisationId = myEvent.OrganisationId,
Title = myEvent.Title,
Description = myEvent.Description,
Description = myEvent.Description ?? "",
Location = myEvent.Location,
EventDate = myEvent.EventDate,
EventSkills = myEvent.EventSkills,
EventRegistrations = myEvent.EventRegistrations
EventSkills = ssdto,
EventRegistrations = erdto
};
}
public static EventSummaryNoErDto ToEventSummaryNoErDto(this Event myEvent)
@@ -54,7 +68,7 @@ public static class EventMapping
myEvent.Organisation!.Name,
myEvent.OrganisationId,
myEvent.Title,
myEvent.Description,
myEvent.Description ?? "",
myEvent.Location,
myEvent.EventDate,
myEvent.EventSkills
@@ -67,7 +81,7 @@ public static class EventMapping
return new EventRegistrationDto {
EventId = myER.EventId,
UserId = myER.UserId,
UserName = myER.User.FirstName + " " + myER.User.LastName,
UserName = myER.User!.FirstName + " " + myER.User!.LastName,
RegisteredAt = myER.RegisteredAt
};
}
@@ -90,9 +104,9 @@ public static class EventMapping
return new EventDetailsDto {
EventId = myEvent.EventId,
OrganisationId = myEvent.OrganisationId,
OrganisationName = myEvent.Organisation.Name,
OrganisationName = myEvent.Organisation!.Name,
Title = myEvent.Title,
Description = myEvent.Description,
Description = myEvent.Description ?? "",
Location = myEvent.Location,
EventDate = myEvent.EventDate,
EventSkills = ssdto,