mirror of
https://github.com/GCMatters/hermes.git
synced 2026-02-04 05:30:13 +01:00
Using to MinimalAPI
Usunalem EventApiController(dobry byl ale mial problemy). Dodalem EventsEndpoints, zawiera async, używa Dtos (Data Transfer Objects). Jeżeli chcecie zrobić HTTP request ale nie wiecie co dać w body JSONa to można sprawdzić w tych Dtos. EventMapping służy do zmian obiektów Dto na Entity i odwrotnie.
This commit is contained in:
15
WebApp/DTOs/EventCreateDto.cs
Normal file
15
WebApp/DTOs/EventCreateDto.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using WebApp.Entities;
|
||||
|
||||
namespace WebApp.DTOs;
|
||||
|
||||
// Input values in JSON file to create event
|
||||
public record class EventCreateDto
|
||||
(
|
||||
[Required] int? OrganisationId,
|
||||
[Required][StringLength(50)] string Title,
|
||||
[StringLength(500)] string Description,
|
||||
[Required][StringLength(100)] string Location,
|
||||
[Required] DateTime? EventDate,
|
||||
ICollection<EventSkill> EventSkills
|
||||
);
|
||||
17
WebApp/DTOs/EventDetailsDto.cs
Normal file
17
WebApp/DTOs/EventDetailsDto.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using WebApp.Entities;
|
||||
|
||||
namespace WebApp.DTOs;
|
||||
|
||||
// Output values in JSON file
|
||||
public record class EventDetailsDto
|
||||
(
|
||||
int EventId,
|
||||
[Required] int? OrganisationId,
|
||||
[Required][StringLength(50)] string Title,
|
||||
[StringLength(500)] string Description,
|
||||
[Required][StringLength(100)] string Location,
|
||||
[Required] DateTime? EventDate,
|
||||
ICollection<EventSkill> EventSkills,
|
||||
ICollection<EventRegistration> EventRegistrations
|
||||
);
|
||||
16
WebApp/DTOs/EventSummaryDto.cs
Normal file
16
WebApp/DTOs/EventSummaryDto.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using WebApp.Entities;
|
||||
|
||||
namespace WebApp.DTOs;
|
||||
|
||||
// Output values in JSON file
|
||||
public record class EventSummaryDto(
|
||||
int EventId,
|
||||
[Required] string Organisation,
|
||||
[Required] [StringLength(50)] string Title,
|
||||
[StringLength(500)] string Description,
|
||||
[Required] [StringLength(100)] string Location,
|
||||
[Required] DateTime? EventDate,
|
||||
ICollection<EventSkill> EventSkills,
|
||||
ICollection<EventRegistration> EventRegistrations
|
||||
);
|
||||
15
WebApp/DTOs/EventUpdateDto.cs
Normal file
15
WebApp/DTOs/EventUpdateDto.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using WebApp.Entities;
|
||||
|
||||
namespace WebApp.DTOs;
|
||||
|
||||
// Input values in JSON file to update event
|
||||
public record class EventUpdateDto
|
||||
(
|
||||
[Required] int? OrganisationId,
|
||||
[Required][StringLength(50)] string Title,
|
||||
[StringLength(500)] string Description,
|
||||
[Required][StringLength(100)] string Location,
|
||||
[Required] DateTime? EventDate,
|
||||
ICollection<EventSkill> EventSkills
|
||||
);
|
||||
@@ -1,15 +0,0 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using WebApp.Entities;
|
||||
|
||||
namespace WebApp.DTOs;
|
||||
public record class EventsDto(
|
||||
int EventId,
|
||||
int OrganisationId, //foreign key
|
||||
[StringLength(200)] string Title,
|
||||
[StringLength(800)] string Description,
|
||||
[StringLength(100)] string Location,
|
||||
DateTime EventDate,
|
||||
Organisation? Organisation,
|
||||
ICollection<EventSkill> EventSkills,
|
||||
ICollection<EventRegistration> EventRegistrations
|
||||
);
|
||||
Reference in New Issue
Block a user