Skip to content

Commit

Permalink
Merge pull request #20 from Team-Wilhelm/minor-changes
Browse files Browse the repository at this point in the history
Manipulating collections sends out all collections
  • Loading branch information
mariaruth1 authored May 24, 2024
2 parents 901d90b + 373a17b commit 1e02979
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 18 deletions.
6 changes: 3 additions & 3 deletions Shared/Dtos/FromClient/Identity/RegisterUserDto.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ namespace Shared.Dtos.FromClient.Identity;

public class RegisterUserDto
{
[EmailAddress] public string Email { get; set; }
[MaxLength(50)] public string Username { get; set; }
[MinLength(8)] [MaxLength(256)] public string Password { get; set; }
[EmailAddress] public required string Email { get; set; }
[MaxLength(50)] public required string Username { get; set; }
[MinLength(8)] [MaxLength(256)] public required string Password { get; set; }
public string? Base64Image { get; set; }
public string? BlobUrl { get; set; }
}
2 changes: 1 addition & 1 deletion api/Events/Auth/Client/ClientWantsToSignUp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace api.Events.Auth.Client;

public class ClientWantsToSignUpDto : BaseDto
{
public RegisterUserDto RegisterUserDto { get; set; }
public required RegisterUserDto RegisterUserDto { get; set; }
}

[ValidateDataAnnotations]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@ public class ClientWantsToCreateCollection(CollectionsService collectionsService
public override async Task Handle(ClientWantsToCreateCollectionDto dto, IWebSocketConnection socket)
{
var email = jwtService.GetEmailFromJwt(dto.Jwt!);
var collection = await collectionsService.CreateCollection(dto.CreateCollectionDto, email);
socket.SendDto(new ServerSavesCollection
await collectionsService.CreateCollection(dto.CreateCollectionDto, email);
var allCollections = await collectionsService.GetCollectionsForUser(email);
socket.SendDto(new ServerSendsAllCollections()
{
Collection = collection
Collections = allCollections.ToList()
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ public override async Task Handle(ClientWantsToDeleteCollectionDto dto, IWebSock
{
var email = jwtService.GetEmailFromJwt(dto.Jwt!);
await collectionsService.DeleteCollection(dto.CollectionId, email);
socket.SendDto(new ServerDeletesCollection());

var allCollections = await collectionsService.GetCollectionsForUser(email);
socket.SendDto(new ServerSendsAllCollections()
{
Collections = allCollections.ToList()
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ public override async Task Handle(ClientWantsToUpdateCollectionDto dto, IWebSock
{
var email = jwtService.GetEmailFromJwt(dto.Jwt!);
var collection = await collectionsService.UpdateCollection(dto.UpdateCollectionDto, email);
socket.SendDto(new ServerSavesCollection
var allCollections = await collectionsService.GetCollectionsForUser(email);
socket.SendDto(new ServerSendsAllCollections()
{
Collection = collection
Collections = allCollections.ToList()
});
}
}
5 changes: 1 addition & 4 deletions api/Events/Global/ServerConfirmsDelete.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,4 @@

namespace api.Events.Global;

public class ServerConfirmsDelete: BaseDto
{

}
public class ServerConfirmsDelete: BaseDto;
5 changes: 2 additions & 3 deletions api/Events/PlantEvents/Client/ClientWantsToDeletePlant.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,9 @@ public class ClientWantsToDeletePlant(PlantService plantService, JwtService jwtS
{
public override async Task Handle(ClientWantsToDeletePlantDto dto, IWebSocketConnection socket)
{
var email = jwtService.GetEmailFromJwt(dto.Jwt);
var email = jwtService.GetEmailFromJwt(dto.Jwt!);
await plantService.DeletePlant(dto.PlantId, email);
var serverConfirmsDelete = new ServerConfirmsDelete();
socket.SendDto(serverConfirmsDelete);
socket.SendDto( new ServerConfirmsDelete());
}
}

0 comments on commit 1e02979

Please sign in to comment.