Adding Comunication
This commit is contained in:
@@ -2,5 +2,7 @@ namespace PyroFetes.DTO.Communication.Request;
|
||||
|
||||
public class CreateCommunicationDto
|
||||
{
|
||||
|
||||
public string? Calling { get; set; }
|
||||
public string? Email { get; set; }
|
||||
public string? Meeting { get; set; }
|
||||
}
|
@@ -2,5 +2,5 @@ namespace PyroFetes.DTO.Communication.Request;
|
||||
|
||||
public class GetCommunicationRequest
|
||||
{
|
||||
|
||||
public int Id { get; set; }
|
||||
}
|
@@ -2,5 +2,8 @@ namespace PyroFetes.DTO.Communication.Request;
|
||||
|
||||
public class UpdateCommunicationDto
|
||||
{
|
||||
|
||||
public int Id { get; set; }
|
||||
public string? Calling { get; set; }
|
||||
public string? Email { get; set; }
|
||||
public string? Meeting { get; set; }
|
||||
}
|
@@ -1,7 +1,8 @@
|
||||
namespace PyroFetes.DTO.Communication.Response;
|
||||
|
||||
public class GetCommunicationRequest
|
||||
public class GetCommunicationDto
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string? Calling { get; set; }
|
||||
public string? Email { get; set; }
|
||||
public string? Meeting { get; set; }
|
||||
|
@@ -1,6 +1,6 @@
|
||||
namespace PyroFetes.DTO.ExperienceLevel.Request;
|
||||
|
||||
public class GetExperienceLevelRequest
|
||||
public class GetExperienceLevelDTO
|
||||
{
|
||||
public int Id { get; set; }
|
||||
}
|
@@ -0,0 +1,36 @@
|
||||
using FastEndpoints;
|
||||
using PyroFetes.DTO.Communication.Request;
|
||||
using PyroFetes.DTO.Communication.Response;
|
||||
|
||||
namespace PyroFetes.Endpoints.Communication;
|
||||
|
||||
public class CreateCommunicationEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoint<CreateCommunicationDto, GetCommunicationDto>
|
||||
{
|
||||
public override void Configure()
|
||||
{
|
||||
Post("/api/communications");
|
||||
AllowAnonymous();
|
||||
}
|
||||
|
||||
|
||||
public override async Task HandleAsync(CreateCommunicationDto req, CancellationToken ct)
|
||||
{
|
||||
Models.Communication communication = new()
|
||||
{
|
||||
Calling = req.Calling,
|
||||
Email = req.Email,
|
||||
Meeting = req.Meeting
|
||||
};
|
||||
pyroFetesDbContext.Add(communication);
|
||||
await pyroFetesDbContext.SaveChangesAsync(ct);
|
||||
|
||||
GetCommunicationDto response = new()
|
||||
{
|
||||
Calling = req.Calling,
|
||||
Email = req.Email,
|
||||
Meeting = req.Meeting
|
||||
};
|
||||
|
||||
await Send.OkAsync(response, ct);
|
||||
}
|
||||
}
|
@@ -0,0 +1,30 @@
|
||||
using FastEndpoints;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using PyroFetes.DTO.Availability.Request;
|
||||
using PyroFetes.DTO.Communication.Response;
|
||||
|
||||
namespace PyroFetes.Endpoints.Communication;
|
||||
|
||||
public class DeleteCommunicationEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoint <GetCommunicationDto, GetCommunicationEndpoint>
|
||||
{
|
||||
public override void Configure()
|
||||
{
|
||||
Delete ("/api/availabilities/{@Id}", x => new { x.Id });
|
||||
AllowAnonymous();
|
||||
}
|
||||
|
||||
public async Task HandleAsync(GetAvailabilityRequest req, CancellationToken ct)
|
||||
{
|
||||
Models.Availability? databaseAvailability = await pyroFetesDbContext.Availabilities.SingleOrDefaultAsync(x => x.Id == req.Id, cancellationToken: ct);
|
||||
|
||||
if (databaseAvailability == null)
|
||||
{
|
||||
await Send.NotFoundAsync(ct);
|
||||
return;
|
||||
}
|
||||
pyroFetesDbContext.Availabilities.Remove(databaseAvailability);
|
||||
await pyroFetesDbContext.SaveChangesAsync(ct);
|
||||
|
||||
await Send.NoContentAsync(ct);
|
||||
}
|
||||
}
|
@@ -0,0 +1,28 @@
|
||||
using FastEndpoints;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using PyroFetes.DTO.Availability.Response;
|
||||
using PyroFetes.DTO.Communication.Response;
|
||||
|
||||
namespace PyroFetes.Endpoints.Communication;
|
||||
|
||||
public class GetCommunicationEndpoint(PyroFetesDbContext pyroFetesDbContext) : EndpointWithoutRequest<List<GetCommunicationDto>>
|
||||
{
|
||||
public override void Configure()
|
||||
{
|
||||
Get ("/api/availabilities");
|
||||
AllowAnonymous();
|
||||
}
|
||||
|
||||
public override async Task HandleAsync(CancellationToken ct)
|
||||
{
|
||||
List<GetCommunicationDto> communications = await pyroFetesDbContext.Communications.Select(x => new GetCommunicationDto()
|
||||
{
|
||||
Id = x.Id,
|
||||
Calling = x.Calling,
|
||||
Email = x.Email,
|
||||
Meeting = x.Meeting,
|
||||
}).ToListAsync(ct);
|
||||
|
||||
await Send.OkAsync(communications, ct);
|
||||
}
|
||||
}
|
@@ -5,7 +5,7 @@ using FastEndpoints;
|
||||
|
||||
namespace PyroFetes.Endpoints.ExperienceLevel;
|
||||
|
||||
public class DeleteExerienceLevelEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoint <GetExperienceLevelRequest, GetExperienceLevelDto>
|
||||
public class DeleteExerienceLevelEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoint <GetExperienceLevelDTO, GetExperienceLevelDto>
|
||||
{
|
||||
public override void Configure()
|
||||
{
|
||||
@@ -13,7 +13,7 @@ public class DeleteExerienceLevelEndpoint(PyroFetesDbContext pyroFetesDbContext)
|
||||
AllowAnonymous();
|
||||
}
|
||||
|
||||
public override async Task HandleAsync(GetExperienceLevelRequest req, CancellationToken ct)
|
||||
public override async Task HandleAsync(GetExperienceLevelDTO req, CancellationToken ct)
|
||||
{
|
||||
Models.ExperienceLevel? databaseExperienceLevel = await pyroFetesDbContext.ExperienceLevels.SingleOrDefaultAsync(x => x.Id == req.Id, cancellationToken: ct);
|
||||
|
||||
|
@@ -5,7 +5,7 @@ using FastEndpoints;
|
||||
|
||||
namespace PyroFetes.Endpoints.ExperienceLevel;
|
||||
|
||||
public class GetExperienceLevelEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoint <GetExperienceLevelRequest, GetExperienceLevelDto>
|
||||
public class GetExperienceLevelEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoint <GetExperienceLevelDTO, GetExperienceLevelDto>
|
||||
{
|
||||
public override void Configure()
|
||||
{
|
||||
@@ -13,7 +13,7 @@ public class GetExperienceLevelEndpoint(PyroFetesDbContext pyroFetesDbContext) :
|
||||
AllowAnonymous();
|
||||
}
|
||||
|
||||
public override async Task HandleAsync(GetExperienceLevelRequest req, CancellationToken ct)
|
||||
public override async Task HandleAsync(GetExperienceLevelDTO req, CancellationToken ct)
|
||||
{
|
||||
Models.ExperienceLevel? databaseExperienceLevel = await pyroFetesDbContext.ExperienceLevels.SingleOrDefaultAsync(x => x.Id == req.Id, cancellationToken: ct);
|
||||
|
||||
|
Reference in New Issue
Block a user