mirror of
https://github.com/GCMatters/hermes.git
synced 2026-02-04 05:30:13 +01:00
65 lines
1.8 KiB
C#
65 lines
1.8 KiB
C#
using Microsoft.EntityFrameworkCore;
|
|
using WebApp.DTOs;
|
|
using WebApp.Entities;
|
|
|
|
namespace WebApp.Mapping;
|
|
|
|
public static class EventMapping
|
|
{
|
|
public static Event ToEntity(this EventCreateDto ECDto)
|
|
{
|
|
return new Event()
|
|
{
|
|
OrganisationId = ECDto.OrganisationId!.Value,
|
|
Title = ECDto.Title,
|
|
Description = ECDto.Description,
|
|
Location = ECDto.Location,
|
|
EventDate = DateTime.SpecifyKind(ECDto.EventDate!.Value, DateTimeKind.Utc),
|
|
EventSkills = ECDto.EventSkills,
|
|
EventRegistrations = []
|
|
};
|
|
}
|
|
|
|
public static Event ToEntity(this EventUpdateDto EUDto, int id)
|
|
{
|
|
return new Event()
|
|
{
|
|
EventId = id,
|
|
OrganisationId = EUDto.OrganisationId!.Value,
|
|
Title = EUDto.Title,
|
|
Description = EUDto.Description,
|
|
Location = EUDto.Location,
|
|
EventDate = DateTime.SpecifyKind(EUDto.EventDate!.Value, DateTimeKind.Utc),
|
|
EventSkills = EUDto.EventSkills
|
|
};
|
|
}
|
|
|
|
public static EventSummaryDto ToEventSummaryDto(this Event myEvent)
|
|
{
|
|
return new EventSummaryDto(
|
|
myEvent.EventId,
|
|
myEvent.Organisation!.Name,
|
|
myEvent.OrganisationId,
|
|
myEvent.Title,
|
|
myEvent.Description,
|
|
myEvent.Location,
|
|
myEvent.EventDate,
|
|
myEvent.EventSkills,
|
|
myEvent.EventRegistrations
|
|
);
|
|
}
|
|
|
|
public static EventDetailsDto ToEventDetailsDto(this Event myEvent)
|
|
{
|
|
return new EventDetailsDto(
|
|
myEvent.EventId,
|
|
myEvent.OrganisationId,
|
|
myEvent.Title,
|
|
myEvent.Description,
|
|
myEvent.Location,
|
|
myEvent.EventDate,
|
|
myEvent.EventSkills,
|
|
myEvent.EventRegistrations
|
|
);
|
|
}
|
|
} |