Modifs communication
This commit is contained in:
@@ -5,4 +5,5 @@ public class CreateCommunicationDto
|
|||||||
public string? Calling { get; set; }
|
public string? Calling { get; set; }
|
||||||
public string? Email { get; set; }
|
public string? Email { get; set; }
|
||||||
public string? Meeting { 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? Calling { get; set; }
|
||||||
public string? Email { get; set; }
|
public string? Email { get; set; }
|
||||||
public string? Meeting { 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,
|
Calling = req.Calling,
|
||||||
Email = req.Email,
|
Email = req.Email,
|
||||||
Meeting = req.Meeting
|
Meeting = req.Meeting,
|
||||||
|
ContactId = req.ContactId
|
||||||
};
|
};
|
||||||
pyroFetesDbContext.Add(communication);
|
pyroFetesDbContext.Add(communication);
|
||||||
await pyroFetesDbContext.SaveChangesAsync(ct);
|
await pyroFetesDbContext.SaveChangesAsync(ct);
|
||||||
|
|
||||||
GetCommunicationDto response = new()
|
GetCommunicationDto response = new()
|
||||||
{
|
{
|
||||||
Calling = req.Calling,
|
Calling = communication.Calling,
|
||||||
Email = req.Email,
|
Email = communication.Email,
|
||||||
Meeting = req.Meeting
|
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);
|
await Send.OkAsync(response, ct);
|
||||||
|
|||||||
@@ -14,12 +14,17 @@ public class GetAllCommunicationsEndpoint(PyroFetesDbContext pyroFetesDbContext)
|
|||||||
|
|
||||||
public override async Task HandleAsync(CancellationToken ct)
|
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,
|
Id = x.Id,
|
||||||
Calling = x.Calling,
|
Calling = x.Calling,
|
||||||
Email = x.Email,
|
Email = x.Email,
|
||||||
Meeting = x.Meeting,
|
Meeting = x.Meeting,
|
||||||
|
ContactId = x.ContactId,
|
||||||
|
ContactFirstName = x.Contact.FirstName,
|
||||||
|
ContactLastName = x.Contact.LastName,
|
||||||
|
ContactPhoneNumber = x.Contact.PhoneNumber,
|
||||||
|
ContactEmail = x.Contact.Email,
|
||||||
}).ToListAsync(ct);
|
}).ToListAsync(ct);
|
||||||
|
|
||||||
await Send.OkAsync(communications, ct);
|
await Send.OkAsync(communications, ct);
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ public class CreateContactEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endp
|
|||||||
Address = contact.Address,
|
Address = contact.Address,
|
||||||
City = contact.City,
|
City = contact.City,
|
||||||
Role = contact.Role,
|
Role = contact.Role,
|
||||||
CustomerId = contact.CustomerId,
|
CustomerId = databaseCustomer.Id,
|
||||||
};
|
};
|
||||||
|
|
||||||
await Send.OkAsync(response, ct);
|
await Send.OkAsync(response, ct);
|
||||||
|
|||||||
Reference in New Issue
Block a user