Modifs communication

This commit is contained in:
2026-06-09 13:29:58 +02:00
parent 7071910dc4
commit a88ce4cc7e
5 changed files with 25 additions and 6 deletions
@@ -5,4 +5,5 @@ public class CreateCommunicationDto
public string? Calling { get; set; }
public string? Email { get; set; }
public string? Meeting { get; set; }
public int ContactId { get; set; }
}
@@ -6,4 +6,11 @@ public class GetCommunicationDto
public string? Calling { get; set; }
public string? Email { get; set; }
public string? Meeting { get; set; }
public int ContactId { get; set; }
public string? ContactFirstName { get; set; }
public string? ContactLastName { get; set; }
public string? ContactEmail { get; set; }
public string? ContactPhoneNumber { get; set; }
}
@@ -19,16 +19,22 @@ public class CreateCommunicationEndpoint(PyroFetesDbContext pyroFetesDbContext)
{
Calling = req.Calling,
Email = req.Email,
Meeting = req.Meeting
Meeting = req.Meeting,
ContactId = req.ContactId
};
pyroFetesDbContext.Add(communication);
await pyroFetesDbContext.SaveChangesAsync(ct);
GetCommunicationDto response = new()
{
Calling = req.Calling,
Email = req.Email,
Meeting = req.Meeting
Calling = communication.Calling,
Email = communication.Email,
Meeting = communication.Meeting,
ContactId = communication.ContactId,
ContactFirstName = communication.Contact?.FirstName,
ContactLastName = communication.Contact?.LastName,
ContactEmail = communication.Contact?.Email,
ContactPhoneNumber = communication.Contact?.PhoneNumber,
};
await Send.OkAsync(response, ct);
@@ -14,12 +14,17 @@ public class GetAllCommunicationsEndpoint(PyroFetesDbContext pyroFetesDbContext)
public override async Task HandleAsync(CancellationToken ct)
{
List<GetCommunicationDto> communications = await pyroFetesDbContext.Communications.Select(x => new GetCommunicationDto()
List<GetCommunicationDto> communications = await pyroFetesDbContext.Communications.Include(x => x.Contact).Select(x => new GetCommunicationDto()
{
Id = x.Id,
Calling = x.Calling,
Email = x.Email,
Meeting = x.Meeting,
ContactId = x.ContactId,
ContactFirstName = x.Contact.FirstName,
ContactLastName = x.Contact.LastName,
ContactPhoneNumber = x.Contact.PhoneNumber,
ContactEmail = x.Contact.Email,
}).ToListAsync(ct);
await Send.OkAsync(communications, ct);
@@ -48,7 +48,7 @@ public class CreateContactEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endp
Address = contact.Address,
City = contact.City,
Role = contact.Role,
CustomerId = contact.CustomerId,
CustomerId = databaseCustomer.Id,
};
await Send.OkAsync(response, ct);