mirror of
https://github.com/GCMatters/hermes.git
synced 2026-02-04 05:30:13 +01:00
feat: replace manual event search in favor of dto builders
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
using WebApp.DTOs;
|
||||
using WebApp.Entities;
|
||||
|
||||
namespace WebApp.Mapping
|
||||
{
|
||||
public static class EventRegistrationMapping
|
||||
{
|
||||
public static EventRegistrationDto ToEventRegistrationDto(this EventRegistration er)
|
||||
{
|
||||
return new EventRegistrationDto(
|
||||
er.EventId,
|
||||
er.UserId,
|
||||
er.RegisteredAt
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user