Skip to content

Commit

Permalink
reshuffle some method calls
Browse files Browse the repository at this point in the history
  • Loading branch information
juuwel committed May 29, 2024
1 parent 91c04d0 commit fe71f75
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ public override async Task Handle(ClientWantsToCreateCollectionDto dto, IWebSock
var email = jwtService.GetEmailFromJwt(dto.Jwt!);
await collectionsService.CreateCollection(dto.CreateCollectionDto, email);
var allCollections = await collectionsService.GetCollectionsForUser(email);
var stats = await statsService.GetStats(email);

socket.SendDto(new ServerSendsAllCollections
{
Collections = allCollections.ToList()
});

var stats = await statsService.GetStats(email);
socket.SendDto(new ServerSendsStats{Stats = stats});
}
}
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,14 +22,14 @@ public override async Task Handle(ClientWantsToCreatePlantDto dto, IWebSocketCon
{
var email = jwtService.GetEmailFromJwt(dto.Jwt!);
var plant = await plantService.CreatePlant(dto.CreatePlantDto, email);
var allPlants = await plantService.GetPlantsForUser(email, 1, 100);

var serverCreatesNewPlant = new ServerSavesPlant
{
Plant = plant
};
socket.SendDto(serverCreatesNewPlant);

var allPlants = await plantService.GetPlantsForUser(email, 1, 100);
socket.SendDto(new ServerSendsPlants
{
Plants = allPlants
Expand Down
4 changes: 2 additions & 2 deletions api/Events/PlantEvents/Client/ClientWantsToDeletePlant.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,17 @@ public class ClientWantsToDeletePlant(PlantService plantService, JwtService jwtS
public override async Task Handle(ClientWantsToDeletePlantDto dto, IWebSocketConnection socket)
{
var email = jwtService.GetEmailFromJwt(dto.Jwt!);
var stats = await statsService.GetStats(email);
var allPlants = await plantService.GetPlantsForUser(email, 1, 100);

await plantService.DeletePlant(dto.PlantId, email);
socket.SendDto( new ServerConfirmsDelete());

var allPlants = await plantService.GetPlantsForUser(email, 1, 100);
socket.SendDto(new ServerSendsPlants
{
Plants = allPlants
});

var stats = await statsService.GetStats(email);
socket.SendDto(new ServerSendsStats{Stats = stats});
}
}
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 @@ -19,20 +19,20 @@ public class ClientWantsToUpdatePlant(PlantService plantService, JwtService jwtS
public override async Task Handle(ClientWantsToUpdatePlantDto dto, IWebSocketConnection socket)
{
var email = jwtService.GetEmailFromJwt(dto.Jwt!);
var plant = await plantService.UpdatePlant(dto.UpdatePlantDto, email);
var stats = await statsService.GetStats(email);
var allPlants = await plantService.GetPlantsForUser(email, 1, 100);

var plant = await plantService.UpdatePlant(dto.UpdatePlantDto, email);
socket.SendDto(new ServerSavesPlant
{
Plant = plant
});

var allPlants = await plantService.GetPlantsForUser(email, 1, 100);
socket.SendDto(new ServerSendsPlants
{
Plants = allPlants
});

var stats = await statsService.GetStats(email);
socket.SendDto(new ServerSendsStats{Stats = stats});
}
}

0 comments on commit fe71f75

Please sign in to comment.