Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

minor changes to support latest FE #14

Merged
merged 1 commit into from
May 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Tests/PlantTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public async Task CreatePlant()

await webSocketTestClient.DoAndAssert(new ClientWantsToCreatePlantDto { CreatePlantDto = createPlantDto, Jwt = jwt }, receivedMessages =>
{
return receivedMessages.Count(e => e.eventType == nameof(ServerCreatesNewPlant)) == 1;
return receivedMessages.Count(e => e.eventType == nameof(ServerSavesPlant)) == 1;
});

await webSocketTestClient.DoAndAssert(new ClientWantsAllPlantsDto
Expand Down
2 changes: 1 addition & 1 deletion api/Events/PlantEvents/Client/ClientWantsToCreatePlant.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public override async Task Handle(ClientWantsToCreatePlantDto dto, IWebSocketCon
var email = jwtService.GetEmailFromJwt(dto.Jwt!);
var plant = await plantService.CreatePlant(dto.CreatePlantDto, email);

var serverCreatesNewPlant = new ServerCreatesNewPlant
var serverCreatesNewPlant = new ServerSavesPlant
{
Plant = plant
};
Expand Down
6 changes: 3 additions & 3 deletions api/Events/PlantEvents/Client/ClientWantsToUpdatePlant.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ namespace api.Events.PlantEvents.Client;

public class ClientWantsToUpdatePlantDto: BaseDtoWithJwt
{
public UpdatePlantDto UpdatePlantDto { get; set; }
public required UpdatePlantDto UpdatePlantDto { get; set; }
}

public class ClientWantsToUpdatePlant(PlantService plantService, JwtService jwtService): BaseEventHandler<ClientWantsToUpdatePlantDto>
{
public override async Task Handle(ClientWantsToUpdatePlantDto dto, IWebSocketConnection socket)
{
var email = jwtService.GetEmailFromJwt(dto.Jwt);
var email = jwtService.GetEmailFromJwt(dto.Jwt!);
var plant = await plantService.UpdatePlant(dto.UpdatePlantDto, email);
socket.SendDto(new ServerSendsPlant
socket.SendDto(new ServerSavesPlant
{
Plant = plant
});
Expand Down
9 changes: 0 additions & 9 deletions api/Events/PlantEvents/Server/ServerCreatesNewPlant.cs

This file was deleted.

9 changes: 9 additions & 0 deletions api/Events/PlantEvents/Server/ServerSavesPlant.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using lib;
using Shared.Models;

namespace api.Events.PlantEvents.Server;

public class ServerSavesPlant : BaseDto
{
public required Plant Plant { get; set; }
}
6 changes: 3 additions & 3 deletions api/Events/User/ClientWantsToUpdateProfile.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using api.EventFilters;
using api.Events.Global;
using api.Extensions;
using Core.Services;
using Fleck;
Expand Down Expand Up @@ -33,7 +34,7 @@ public override async Task Handle(ClientWantsToUpdateUserDto dto, IWebSocketConn
var user = await userService.GetUserByEmail(email);
socket.SendDto(new ServerRejectsUpdate
{
ErrorMessage = "Update failed",
Error = "Update failed",
GetUserDto =new GetUserDto
{
UserEmail = email,
Expand All @@ -50,8 +51,7 @@ public class ServerConfirmsUpdate : BaseDto
public GetUserDto GetUserDto { get; set; } = null!;
}

public class ServerRejectsUpdate : BaseDto
public class ServerRejectsUpdate : ServerSendsErrorMessage
{
public string ErrorMessage { get; set; } = null!;
public GetUserDto? GetUserDto { get; set; }
}
Loading