Compare commits
23 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
dc9aa8c840 | ||
|
|
3b178144ae | ||
| 3a83372403 | |||
| da3def1eea | |||
|
|
b7ad3c9af3 | ||
|
|
696ec3da80 | ||
|
|
55d50cf3df | ||
| 74cab09948 | |||
| db76d50079 | |||
| 747cb84f88 | |||
| fd33ac4744 | |||
|
|
89cd408e5c | ||
|
|
7bf2a01a4f | ||
| 7ede95db7c | |||
|
|
2258e5ad8e | ||
|
|
fe4c8d4080 | ||
| cec5946234 | |||
|
|
f2e4058b04 | ||
|
|
267eb537c9 | ||
|
|
6c019947d5 | ||
| 2444e31f4f | |||
| e116708b76 | |||
| 7df0a396f2 |
17
.idea/.idea.Knots/.idea/dataSources.xml
generated
Normal file
17
.idea/.idea.Knots/.idea/dataSources.xml
generated
Normal file
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="DataSourceManagerImpl" format="xml" multifile-model="true">
|
||||
<data-source source="LOCAL" name="@romaric-thibault.fr" uuid="2e0ff1eb-4394-46d9-aa2d-362392df37df">
|
||||
<driver-ref>sqlserver.jb</driver-ref>
|
||||
<synchronize>true</synchronize>
|
||||
<jdbc-driver>com.jetbrains.jdbc.sqlserver.SqlServerDriver</jdbc-driver>
|
||||
<jdbc-url>Server=romaric-thibault.fr,1433</jdbc-url>
|
||||
<jdbc-additional-properties>
|
||||
<property name="com.intellij.clouds.kubernetes.db.host.port" />
|
||||
<property name="com.intellij.clouds.kubernetes.db.enabled" value="false" />
|
||||
<property name="com.intellij.clouds.kubernetes.db.container.port" />
|
||||
</jdbc-additional-properties>
|
||||
<working-dir>$ProjectFileDir$</working-dir>
|
||||
</data-source>
|
||||
</component>
|
||||
</project>
|
||||
6
Knots/DTO/Discussion/CreateDiscussionDto.cs
Normal file
6
Knots/DTO/Discussion/CreateDiscussionDto.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
namespace Knots.DTO.Discussion;
|
||||
|
||||
public class CreateDiscussionDto
|
||||
{
|
||||
public int Id { get; set; }
|
||||
}
|
||||
6
Knots/DTO/Discussion/DeleteDiscussionDto.cs
Normal file
6
Knots/DTO/Discussion/DeleteDiscussionDto.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
namespace Knots.DTO.Discussion;
|
||||
|
||||
public class DeleteDiscussionDto
|
||||
{
|
||||
public int Id { get; set; }
|
||||
}
|
||||
6
Knots/DTO/Discussion/GetDiscussionDto.cs
Normal file
6
Knots/DTO/Discussion/GetDiscussionDto.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
namespace Knots.DTO.Discussion;
|
||||
|
||||
public class GetDiscussionDto
|
||||
{
|
||||
public int Id { get; set; }
|
||||
}
|
||||
8
Knots/DTO/Group/CreateGroupDto.cs
Normal file
8
Knots/DTO/Group/CreateGroupDto.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
namespace Knots.DTO.Group;
|
||||
|
||||
public class CreateGroupDto
|
||||
{
|
||||
public string? Nom { get; set; }
|
||||
public int NombreMembres { get; set; }
|
||||
public string? ProfilePicture { get; set; }
|
||||
}
|
||||
6
Knots/DTO/Group/DeleteGroupDto.cs
Normal file
6
Knots/DTO/Group/DeleteGroupDto.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
namespace Knots.DTO.Group;
|
||||
|
||||
public class DeleteGroupDto
|
||||
{
|
||||
public string? Id { get; set; }
|
||||
}
|
||||
9
Knots/DTO/Group/GetGroupDetailsDto.cs
Normal file
9
Knots/DTO/Group/GetGroupDetailsDto.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
namespace Knots.DTO.Group;
|
||||
|
||||
public class GetGroupDetailsDto
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string? Nom { get; set; }
|
||||
public int NombreMembres { get; set; }
|
||||
public string? ProfilePicture { get; set; }
|
||||
}
|
||||
6
Knots/DTO/Group/GetGroupDto.cs
Normal file
6
Knots/DTO/Group/GetGroupDto.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
namespace Knots.DTO.Group;
|
||||
|
||||
public class GetGroupDto
|
||||
{
|
||||
public int Id { get; set; }
|
||||
}
|
||||
9
Knots/DTO/Group/UpdateGroupDto.cs
Normal file
9
Knots/DTO/Group/UpdateGroupDto.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
namespace Knots.DTO.Group;
|
||||
|
||||
public class UpdateGroupDto
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string? Nom { get; set; }
|
||||
public int NombreMembres { get; set; }
|
||||
public string? ProfilePicture { get; set; }
|
||||
}
|
||||
6
Knots/DTO/Group/UpdateGroupNomDto.cs
Normal file
6
Knots/DTO/Group/UpdateGroupNomDto.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
namespace Knots.DTO.Group;
|
||||
|
||||
public class UpdateGroupNomDto
|
||||
{
|
||||
public string? Nom { get; set; }
|
||||
}
|
||||
6
Knots/DTO/Group/UpdateGroupNombreMembresDto.cs
Normal file
6
Knots/DTO/Group/UpdateGroupNombreMembresDto.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
namespace Knots.DTO.Group;
|
||||
|
||||
public class UpdateGroupNombreMembresDto
|
||||
{
|
||||
public int NombreMembres { get; set; }
|
||||
}
|
||||
6
Knots/DTO/Group/UpdateGroupProfilePictureDto.cs
Normal file
6
Knots/DTO/Group/UpdateGroupProfilePictureDto.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
namespace Knots.DTO.Group;
|
||||
|
||||
public class UpdateGroupProfilePictureDto
|
||||
{
|
||||
public string? ProfilePicture { get; set; }
|
||||
}
|
||||
6
Knots/DTO/Key/CreateKeyDto.cs
Normal file
6
Knots/DTO/Key/CreateKeyDto.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
namespace Knots.DTO.Key;
|
||||
|
||||
public class CreateKeyDto
|
||||
{
|
||||
public string? EnKey { get; set; }
|
||||
}
|
||||
6
Knots/DTO/Key/DeleteKeyDto.cs
Normal file
6
Knots/DTO/Key/DeleteKeyDto.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
namespace Knots.DTO.Key;
|
||||
|
||||
public class DeleteKeyDto
|
||||
{
|
||||
public int Id { get; set; }
|
||||
}
|
||||
7
Knots/DTO/Key/GetKeyDetailsDto.cs
Normal file
7
Knots/DTO/Key/GetKeyDetailsDto.cs
Normal file
@@ -0,0 +1,7 @@
|
||||
namespace Knots.DTO.Key;
|
||||
|
||||
public class GetKeyDetailsDto
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string? EnKey { get; set; }
|
||||
}
|
||||
6
Knots/DTO/Key/GetKeyDto.cs
Normal file
6
Knots/DTO/Key/GetKeyDto.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
namespace Knots.DTO.Key;
|
||||
|
||||
public class GetKeyDto
|
||||
{
|
||||
public int Id { get; set; }
|
||||
}
|
||||
8
Knots/DTO/Message/CreateMessageDto.cs
Normal file
8
Knots/DTO/Message/CreateMessageDto.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
namespace Knots.DTO.Message;
|
||||
|
||||
public class CreateMessageDto
|
||||
{
|
||||
public string? Contenu { get; set; }
|
||||
public DateTime Date { get; set; }
|
||||
public Boolean Type { get; set; }
|
||||
}
|
||||
6
Knots/DTO/Message/DeleteMessageDto.cs
Normal file
6
Knots/DTO/Message/DeleteMessageDto.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
namespace Knots.DTO.Message;
|
||||
|
||||
public class DeleteMessageDto
|
||||
{
|
||||
public int Id { get; set; }
|
||||
}
|
||||
8
Knots/DTO/Message/GetMessageDetailsDto.cs
Normal file
8
Knots/DTO/Message/GetMessageDetailsDto.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
namespace Knots.DTO.Message;
|
||||
|
||||
public class GetMessageDetailsDto
|
||||
{
|
||||
public string? Contenu { get; set; }
|
||||
public DateTime Date { get; set; }
|
||||
public Boolean Type { get; set; }
|
||||
}
|
||||
6
Knots/DTO/Message/GetMessageDto.cs
Normal file
6
Knots/DTO/Message/GetMessageDto.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
namespace Knots.DTO.Message;
|
||||
|
||||
public class GetMessageDto
|
||||
{
|
||||
public int Id { get; set; }
|
||||
}
|
||||
7
Knots/DTO/Message/UpdateMessageDto.cs
Normal file
7
Knots/DTO/Message/UpdateMessageDto.cs
Normal file
@@ -0,0 +1,7 @@
|
||||
namespace Knots.DTO.Message;
|
||||
|
||||
public class UpdateMessageDto
|
||||
{
|
||||
public string? Contenu { get; set; }
|
||||
public DateTime Date { get; set; }
|
||||
}
|
||||
6
Knots/DTO/Role/CreateRoleDto.cs
Normal file
6
Knots/DTO/Role/CreateRoleDto.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
namespace Knots.DTO.Role;
|
||||
|
||||
public class CreateRoleDto
|
||||
{
|
||||
public string? Libelle { get; set; }
|
||||
}
|
||||
6
Knots/DTO/Role/DeleteRoleDto.cs
Normal file
6
Knots/DTO/Role/DeleteRoleDto.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
namespace Knots.DTO.Role;
|
||||
|
||||
public class DeleteRoleDto
|
||||
{
|
||||
public int Id { get; set; }
|
||||
}
|
||||
6
Knots/DTO/Role/GetRoleDto.cs
Normal file
6
Knots/DTO/Role/GetRoleDto.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
namespace Knots.DTO.Role;
|
||||
|
||||
public class GetRoleDto
|
||||
{
|
||||
public string? Libelle { get; set; }
|
||||
}
|
||||
11
Knots/DTO/User/CreateUserDto.cs
Normal file
11
Knots/DTO/User/CreateUserDto.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
namespace Knots.DTO.User;
|
||||
|
||||
public class CreateUserDto
|
||||
{
|
||||
public string? Username { get; set; }
|
||||
public string? Description {get; set;}
|
||||
public string? Password { get; set; }
|
||||
public string? Email { get; set; }
|
||||
public string? Tel { get; set; }
|
||||
public string? ProfilePicture { get; set; }
|
||||
}
|
||||
6
Knots/DTO/User/DeleteUserDto.cs
Normal file
6
Knots/DTO/User/DeleteUserDto.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
namespace Knots.DTO.User;
|
||||
|
||||
public class DeleteUserDto
|
||||
{
|
||||
public string? Username { get; set; }
|
||||
}
|
||||
11
Knots/DTO/User/GetUserDetailsDto.cs
Normal file
11
Knots/DTO/User/GetUserDetailsDto.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
namespace Knots.DTO.User;
|
||||
|
||||
public class GetUserDetailsDto
|
||||
{
|
||||
public string? Username { get; set; }
|
||||
public string? Description {get; set;}
|
||||
public string? Password { get; set; }
|
||||
public string? Email { get; set; }
|
||||
public string? Tel { get; set; }
|
||||
public string? ProfilePicture { get; set; }
|
||||
}
|
||||
6
Knots/DTO/User/GetUserDto.cs
Normal file
6
Knots/DTO/User/GetUserDto.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
namespace Knots.DTO.User;
|
||||
|
||||
public class GetUserDto
|
||||
{
|
||||
public string? Username { get; set; }
|
||||
}
|
||||
6
Knots/DTO/User/UpdateUserDescriptionDto.cs
Normal file
6
Knots/DTO/User/UpdateUserDescriptionDto.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
namespace Knots.DTO.User;
|
||||
|
||||
public class UpdateUserDescriptionDto
|
||||
{
|
||||
public string? Description {get; set;}
|
||||
}
|
||||
11
Knots/DTO/User/UpdateUserDto.cs
Normal file
11
Knots/DTO/User/UpdateUserDto.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
namespace Knots.DTO.User;
|
||||
|
||||
public class UpdateUserDto
|
||||
{
|
||||
public string? Username { get; set; }
|
||||
public string? Description {get; set;}
|
||||
public string? Password { get; set; }
|
||||
public string? Email { get; set; }
|
||||
public string? Tel { get; set; }
|
||||
public string? ProfilePicture { get; set; }
|
||||
}
|
||||
6
Knots/DTO/User/UpdateUserEmailDto.cs
Normal file
6
Knots/DTO/User/UpdateUserEmailDto.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
namespace Knots.DTO.User;
|
||||
|
||||
public class UpdateUserEmailDto
|
||||
{
|
||||
public string? Email { get; set; }
|
||||
}
|
||||
6
Knots/DTO/User/UpdateUserPasswordDto.cs
Normal file
6
Knots/DTO/User/UpdateUserPasswordDto.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
namespace Knots.DTO.User;
|
||||
|
||||
public class UpdateUserPasswordDto
|
||||
{
|
||||
public string? Password { get; set; }
|
||||
}
|
||||
6
Knots/DTO/User/UpdateUserProfilePictureDto.cs
Normal file
6
Knots/DTO/User/UpdateUserProfilePictureDto.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
namespace Knots.DTO.User;
|
||||
|
||||
public class UpdateUserProfilePictureDto
|
||||
{
|
||||
public string? ProfilePicture { get; set; }
|
||||
}
|
||||
6
Knots/DTO/User/UpdateUserTelDto.cs
Normal file
6
Knots/DTO/User/UpdateUserTelDto.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
namespace Knots.DTO.User;
|
||||
|
||||
public class UpdateUserTelDto
|
||||
{
|
||||
public string? Tel { get; set; }
|
||||
}
|
||||
6
Knots/DTO/User/UpdateUsernameDto.cs
Normal file
6
Knots/DTO/User/UpdateUsernameDto.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
namespace Knots.DTO.User;
|
||||
|
||||
public class UpdateUsernameDto
|
||||
{
|
||||
public string? Username { get; set; }
|
||||
}
|
||||
32
Knots/Endpoints/Discussion/CreateDiscussionEndpoint.cs
Normal file
32
Knots/Endpoints/Discussion/CreateDiscussionEndpoint.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using FastEndpoints;
|
||||
using Knots.DTO.Discussion;
|
||||
using Knots.DTO.User;
|
||||
|
||||
namespace Knots.Endpoints.Discussion;
|
||||
|
||||
public class CreateUserEndpoint(KnotsDbContext knotsDbContext) : Endpoint<CreateDiscussionDto, GetDiscussionDto>
|
||||
{
|
||||
public override void Configure()
|
||||
{
|
||||
Post("/users");
|
||||
AllowAnonymous();
|
||||
}
|
||||
|
||||
public override async Task HandleAsync(CreateDiscussionDto req, CancellationToken ct)
|
||||
{
|
||||
Models.Discussion discussion = new()
|
||||
{
|
||||
|
||||
};
|
||||
knotsDbContext.Add(discussion);
|
||||
await knotsDbContext.SaveChangesAsync(ct);
|
||||
|
||||
GetDiscussionDto response = new()
|
||||
{
|
||||
Id = discussion.Id,
|
||||
};
|
||||
|
||||
await Send.OkAsync(response, ct);
|
||||
|
||||
}
|
||||
}
|
||||
6
Knots/Endpoints/Discussion/DeleteDiscussionEndpoint.cs
Normal file
6
Knots/Endpoints/Discussion/DeleteDiscussionEndpoint.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
namespace Knots.Endpoints.Discussion;
|
||||
|
||||
public class DeleteDiscussionEndpoint
|
||||
{
|
||||
|
||||
}
|
||||
6
Knots/Endpoints/Discussion/GetDiscussionEndpoint.cs
Normal file
6
Knots/Endpoints/Discussion/GetDiscussionEndpoint.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
namespace Knots.Endpoints.Discussion;
|
||||
|
||||
public class GetDiscussionEndpoint
|
||||
{
|
||||
|
||||
}
|
||||
6
Knots/Endpoints/Group/CreateGroupEndpoint.cs
Normal file
6
Knots/Endpoints/Group/CreateGroupEndpoint.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
namespace Knots.Endpoints.Group;
|
||||
|
||||
public class CreateGroupEndpoint
|
||||
{
|
||||
|
||||
}
|
||||
6
Knots/Endpoints/Group/DeleteGroupEndpoint.cs
Normal file
6
Knots/Endpoints/Group/DeleteGroupEndpoint.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
namespace Knots.Endpoints.Group;
|
||||
|
||||
public class DeleteGroupEndpoint
|
||||
{
|
||||
|
||||
}
|
||||
6
Knots/Endpoints/Group/GetGroupEndpoint.cs
Normal file
6
Knots/Endpoints/Group/GetGroupEndpoint.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
namespace Knots.Endpoints.Group;
|
||||
|
||||
public class GetGroupEndpoint
|
||||
{
|
||||
|
||||
}
|
||||
6
Knots/Endpoints/Key/CreateKeyEndpoint.cs
Normal file
6
Knots/Endpoints/Key/CreateKeyEndpoint.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
namespace Knots.Endpoints.Key;
|
||||
|
||||
public class CreateKeyEndpoint
|
||||
{
|
||||
|
||||
}
|
||||
6
Knots/Endpoints/Key/DeleteKeyEndpoint.cs
Normal file
6
Knots/Endpoints/Key/DeleteKeyEndpoint.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
namespace Knots.Endpoints.Key;
|
||||
|
||||
public class DeleteKeyEndpoint
|
||||
{
|
||||
|
||||
}
|
||||
6
Knots/Endpoints/Key/GetKeyEndpoint.cs
Normal file
6
Knots/Endpoints/Key/GetKeyEndpoint.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
namespace Knots.Endpoints.Key;
|
||||
|
||||
public class GetKeyEndpoint
|
||||
{
|
||||
|
||||
}
|
||||
6
Knots/Endpoints/Message/CreateMessageEndpoint.cs
Normal file
6
Knots/Endpoints/Message/CreateMessageEndpoint.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
namespace Knots.Endpoints.Message;
|
||||
|
||||
public class CreateMessageEndpoint
|
||||
{
|
||||
|
||||
}
|
||||
6
Knots/Endpoints/Message/DeleteMessageEndpoint.cs
Normal file
6
Knots/Endpoints/Message/DeleteMessageEndpoint.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
namespace Knots.Endpoints.Message;
|
||||
|
||||
public class DeleteMessageEndpoint
|
||||
{
|
||||
|
||||
}
|
||||
6
Knots/Endpoints/Message/GetMessageEndpoint.cs
Normal file
6
Knots/Endpoints/Message/GetMessageEndpoint.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
namespace Knots.Endpoints.Message;
|
||||
|
||||
public class GetMessageEndpoint
|
||||
{
|
||||
|
||||
}
|
||||
32
Knots/Endpoints/Role/CreateRoleEndpoint.cs
Normal file
32
Knots/Endpoints/Role/CreateRoleEndpoint.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using FastEndpoints;
|
||||
using Knots.DTO.Role;
|
||||
using Knots.DTO.User;
|
||||
|
||||
namespace Knots.Endpoints.Role;
|
||||
|
||||
public class CreateRoleEndpoint(KnotsDbContext knotsDbContext) : Endpoint<CreateRoleDto, GetRoleDto>
|
||||
{
|
||||
public override void Configure()
|
||||
{
|
||||
Post("/roles");
|
||||
AllowAnonymous();
|
||||
}
|
||||
|
||||
public override async Task HandleAsync(CreateRoleDto req, CancellationToken ct)
|
||||
{
|
||||
Models.Role role = new()
|
||||
{
|
||||
Libelle = req.Libelle
|
||||
};
|
||||
knotsDbContext.Add(role);
|
||||
await knotsDbContext.SaveChangesAsync(ct);
|
||||
|
||||
GetRoleDto response = new()
|
||||
{
|
||||
Libelle = role.Libelle
|
||||
};
|
||||
|
||||
await Send.OkAsync(response, ct);
|
||||
|
||||
}
|
||||
}
|
||||
33
Knots/Endpoints/Role/GetRoleEndpoint.cs
Normal file
33
Knots/Endpoints/Role/GetRoleEndpoint.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using FastEndpoints;
|
||||
using Knots.DTO.Role;
|
||||
using Knots.DTO.User;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Knots.Endpoints.Role;
|
||||
|
||||
public class GetRoleEndpoint(KnotsDbContext knotsDbContext) : Endpoint <GetRoleDto>
|
||||
{
|
||||
public override void Configure()
|
||||
{
|
||||
Get ("/roles/{@Id}", x => new { x.Libelle });
|
||||
AllowAnonymous();
|
||||
}
|
||||
|
||||
public override async Task HandleAsync(GetRoleDto req, CancellationToken ct)
|
||||
{
|
||||
Models.Role? databaseRole = await knotsDbContext.Roles.SingleOrDefaultAsync(x => x.Libelle == req.Libelle, cancellationToken: ct);
|
||||
|
||||
if (databaseRole == null)
|
||||
{
|
||||
await Send.NotFoundAsync(ct);
|
||||
return;
|
||||
}
|
||||
|
||||
GetRoleDto dto = new()
|
||||
{
|
||||
Libelle = databaseRole.Libelle,
|
||||
};
|
||||
|
||||
await Send.OkAsync(dto, ct);
|
||||
}
|
||||
}
|
||||
36
Knots/Endpoints/User/CreateUserEndpoint.cs
Normal file
36
Knots/Endpoints/User/CreateUserEndpoint.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using FastEndpoints;
|
||||
using Knots.DTO.User;
|
||||
|
||||
namespace Knots.Endpoints.User;
|
||||
|
||||
public class CreateUserEndpoint(KnotsDbContext knotsDbContext) : Endpoint<CreateUserDto, GetUserDto>
|
||||
{
|
||||
public override void Configure()
|
||||
{
|
||||
Post("/users");
|
||||
AllowAnonymous();
|
||||
}
|
||||
|
||||
public override async Task HandleAsync(CreateUserDto req, CancellationToken ct)
|
||||
{
|
||||
Models.User user = new()
|
||||
{
|
||||
Username = req.Username,
|
||||
Description = req.Description,
|
||||
Password = req.Password,
|
||||
Email = req.Email,
|
||||
Tel = req.Tel,
|
||||
ProfilePicture = req.ProfilePicture
|
||||
};
|
||||
knotsDbContext.Add(user);
|
||||
await knotsDbContext.SaveChangesAsync(ct);
|
||||
|
||||
GetUserDto response = new()
|
||||
{
|
||||
Username = user.Username
|
||||
};
|
||||
|
||||
await Send.OkAsync(response, ct);
|
||||
|
||||
}
|
||||
}
|
||||
28
Knots/Endpoints/User/DeleteUserEndpoint.cs
Normal file
28
Knots/Endpoints/User/DeleteUserEndpoint.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using FastEndpoints;
|
||||
using Knots.DTO.User;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Knots.Endpoints.User;
|
||||
|
||||
public class DeleteUserEndpoint(KnotsDbContext knotsDbContext) : Endpoint <GetUserDto, GetUserDetailsDto>
|
||||
{
|
||||
public override void Configure()
|
||||
{
|
||||
Delete ("/users/{@Id}", x => new { x.Username });
|
||||
}
|
||||
|
||||
public override async Task HandleAsync(GetUserDto req, CancellationToken ct)
|
||||
{
|
||||
Models.User? databaseUser = await knotsDbContext.Users.SingleOrDefaultAsync(x => x.Username == req.Username, cancellationToken: ct);
|
||||
|
||||
if (databaseUser == null)
|
||||
{
|
||||
await Send.NotFoundAsync(ct);
|
||||
return;
|
||||
}
|
||||
knotsDbContext.Users.Remove(databaseUser);
|
||||
await knotsDbContext.SaveChangesAsync(ct);
|
||||
|
||||
await Send.NoContentAsync(ct);
|
||||
}
|
||||
}
|
||||
24
Knots/Endpoints/User/GetAllUsersEndpoint.cs
Normal file
24
Knots/Endpoints/User/GetAllUsersEndpoint.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using FastEndpoints;
|
||||
using Knots.DTO.User;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Knots.Endpoints.User;
|
||||
|
||||
public class GetAllUsersEndpoint(KnotsDbContext knotsDbContext) : EndpointWithoutRequest<List<GetUserDto>>
|
||||
{
|
||||
public override void Configure()
|
||||
{
|
||||
Get ("/users");
|
||||
AllowAnonymous();
|
||||
}
|
||||
|
||||
public override async Task HandleAsync(CancellationToken ct)
|
||||
{
|
||||
List<GetUserDto> users= await knotsDbContext.Users.Select(x => new GetUserDto()
|
||||
{
|
||||
Username = x.Username,
|
||||
}).ToListAsync(ct);
|
||||
|
||||
await Send.OkAsync(users, ct);
|
||||
}
|
||||
}
|
||||
37
Knots/Endpoints/User/GetUserEndpoint.cs
Normal file
37
Knots/Endpoints/User/GetUserEndpoint.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using FastEndpoints;
|
||||
using Knots.DTO.User;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Knots.Endpoints.User;
|
||||
|
||||
public class GetUserEndpoint(KnotsDbContext knotsDbContext) : Endpoint <GetUserDto, GetUserDetailsDto>
|
||||
{
|
||||
public override void Configure()
|
||||
{
|
||||
Get ("/users/{@Id}", x => new { x.Username });
|
||||
AllowAnonymous();
|
||||
}
|
||||
|
||||
public override async Task HandleAsync(GetUserDto req, CancellationToken ct)
|
||||
{
|
||||
Models.User? databaseLogin = await knotsDbContext.Users.SingleOrDefaultAsync(x => x.Username == req.Username, cancellationToken: ct);
|
||||
|
||||
if (databaseLogin == null)
|
||||
{
|
||||
await Send.NotFoundAsync(ct);
|
||||
return;
|
||||
}
|
||||
|
||||
GetUserDetailsDto dto = new()
|
||||
{
|
||||
Username = databaseLogin.Username,
|
||||
Description = databaseLogin.Description,
|
||||
Password = databaseLogin.Password,
|
||||
Email = databaseLogin.Email,
|
||||
Tel = databaseLogin.Tel,
|
||||
ProfilePicture = databaseLogin.ProfilePicture
|
||||
};
|
||||
|
||||
await Send.OkAsync(dto, ct);
|
||||
}
|
||||
}
|
||||
46
Knots/Endpoints/User/UpdateUserEndpoint.cs
Normal file
46
Knots/Endpoints/User/UpdateUserEndpoint.cs
Normal file
@@ -0,0 +1,46 @@
|
||||
using FastEndpoints;
|
||||
using Knots.DTO.User;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Knots.Endpoints.User;
|
||||
|
||||
public class UpdateUserEndpoint(KnotsDbContext knotsDbContext) : Endpoint <UpdateUserDto, GetUserDetailsDto>
|
||||
{
|
||||
public override void Configure()
|
||||
{
|
||||
Put ("/users/{@Id}", x => new { x.Username });
|
||||
}
|
||||
|
||||
public override async Task HandleAsync(UpdateUserDto req, CancellationToken ct)
|
||||
{
|
||||
Models.User? databaseUser = await knotsDbContext.Users.SingleOrDefaultAsync(x => x.Username == req.Username, cancellationToken: ct);
|
||||
|
||||
if (databaseUser == null)
|
||||
{
|
||||
await Send.NotFoundAsync(ct);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
databaseUser.Username = req.Username;
|
||||
databaseUser.Password = req.Password;
|
||||
databaseUser.Description = req.Description;
|
||||
databaseUser.Tel = req.Tel;
|
||||
databaseUser.Email = req.Email;
|
||||
databaseUser.ProfilePicture = req.ProfilePicture;
|
||||
}
|
||||
await knotsDbContext.SaveChangesAsync(ct);
|
||||
|
||||
GetUserDetailsDto dto = new()
|
||||
{
|
||||
Username = databaseUser.Username,
|
||||
Password = databaseUser.Password,
|
||||
Description = databaseUser.Description,
|
||||
Tel = databaseUser.Tel,
|
||||
Email = databaseUser.Email,
|
||||
ProfilePicture = databaseUser.ProfilePicture
|
||||
};
|
||||
|
||||
await Send.OkAsync(dto, ct);
|
||||
}
|
||||
}
|
||||
@@ -1,19 +1,26 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net9.0</TargetFramework>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="9.0.8"/>
|
||||
<PackageReference Include="FastEndpoints" Version="8.0.1" />
|
||||
<PackageReference Include="FastEndpoints.Swagger" Version="8.0.1" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.25" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.25" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.25">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.25" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="DTO\" />
|
||||
<Folder Include="Endpoints\" />
|
||||
<Folder Include="Validators\" />
|
||||
<Folder Include="Migrations\" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
33
Knots/KnotsDbContext.cs
Normal file
33
Knots/KnotsDbContext.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using Knots.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Knots;
|
||||
|
||||
public class KnotsDbContext : DbContext
|
||||
{
|
||||
public DbSet<Discussion> Discussions { get; set; }
|
||||
public DbSet<Group> Groups { get; set; }
|
||||
public DbSet<Key> Keys { get; set; }
|
||||
public DbSet<Message> Messages { get; set; }
|
||||
public DbSet<Role> Roles { get; set; }
|
||||
public DbSet<User> Users { get; set; }
|
||||
|
||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||
{
|
||||
//Infos de connexion à la base de données
|
||||
string connectionString =
|
||||
"Server=romaric-thibault.fr;" +
|
||||
"Database=Knots;" +
|
||||
"User Id=mathieu;" +
|
||||
"Password=Onto9-Cage-Afflicted;" +
|
||||
"TrustServerCertificate=true;";
|
||||
|
||||
optionsBuilder.UseSqlServer(connectionString);
|
||||
}
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
|
||||
{
|
||||
//Données à insérer
|
||||
}
|
||||
}
|
||||
165
Knots/Migrations/20260312155557_Initial.Designer.cs
generated
Normal file
165
Knots/Migrations/20260312155557_Initial.Designer.cs
generated
Normal file
@@ -0,0 +1,165 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using Knots;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Knots.Migrations
|
||||
{
|
||||
[DbContext(typeof(KnotsDbContext))]
|
||||
[Migration("20260312155557_Initial")]
|
||||
partial class Initial
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "8.0.25")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||
|
||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("Knots.Models.Discussion", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Discussions");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Knots.Models.Group", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Nom")
|
||||
.IsRequired()
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("nvarchar(50)");
|
||||
|
||||
b.Property<int>("NombreMembres")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("ProfilePicture")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Groups");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Knots.Models.Key", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("EnKey")
|
||||
.IsRequired()
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("nvarchar(50)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Keys");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Knots.Models.Message", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Contenu")
|
||||
.IsRequired()
|
||||
.HasMaxLength(1000)
|
||||
.HasColumnType("nvarchar(1000)");
|
||||
|
||||
b.Property<DateTime>("Date")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<bool>("Type")
|
||||
.HasColumnType("bit");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Messages");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Knots.Models.Role", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Libelle")
|
||||
.IsRequired()
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("nvarchar(50)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Roles");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Knots.Models.User", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Description")
|
||||
.HasMaxLength(200)
|
||||
.HasColumnType("nvarchar(200)");
|
||||
|
||||
b.Property<string>("Email")
|
||||
.IsRequired()
|
||||
.HasMaxLength(70)
|
||||
.HasColumnType("nvarchar(70)");
|
||||
|
||||
b.Property<string>("Password")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("ProfilePicture")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Tel")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Username")
|
||||
.IsRequired()
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("nvarchar(50)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Users");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
123
Knots/Migrations/20260312155557_Initial.cs
Normal file
123
Knots/Migrations/20260312155557_Initial.cs
Normal file
@@ -0,0 +1,123 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Knots.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class Initial : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Discussions",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1")
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Discussions", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Groups",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
Nom = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
|
||||
NombreMembres = table.Column<int>(type: "int", nullable: false),
|
||||
ProfilePicture = table.Column<string>(type: "nvarchar(max)", nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Groups", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Keys",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
EnKey = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Keys", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Messages",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
Contenu = table.Column<string>(type: "nvarchar(1000)", maxLength: 1000, nullable: false),
|
||||
Date = table.Column<DateTime>(type: "datetime2", nullable: false),
|
||||
Type = table.Column<bool>(type: "bit", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Messages", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Roles",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
Libelle = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Roles", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Users",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
Username = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
|
||||
Description = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: true),
|
||||
Password = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Email = table.Column<string>(type: "nvarchar(70)", maxLength: 70, nullable: false),
|
||||
Tel = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
ProfilePicture = table.Column<string>(type: "nvarchar(max)", nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Users", x => x.Id);
|
||||
});
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "Discussions");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Groups");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Keys");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Messages");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Roles");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Users");
|
||||
}
|
||||
}
|
||||
}
|
||||
162
Knots/Migrations/KnotsDbContextModelSnapshot.cs
Normal file
162
Knots/Migrations/KnotsDbContextModelSnapshot.cs
Normal file
@@ -0,0 +1,162 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using Knots;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Knots.Migrations
|
||||
{
|
||||
[DbContext(typeof(KnotsDbContext))]
|
||||
partial class KnotsDbContextModelSnapshot : ModelSnapshot
|
||||
{
|
||||
protected override void BuildModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "8.0.25")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||
|
||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("Knots.Models.Discussion", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Discussions");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Knots.Models.Group", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Nom")
|
||||
.IsRequired()
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("nvarchar(50)");
|
||||
|
||||
b.Property<int>("NombreMembres")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("ProfilePicture")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Groups");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Knots.Models.Key", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("EnKey")
|
||||
.IsRequired()
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("nvarchar(50)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Keys");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Knots.Models.Message", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Contenu")
|
||||
.IsRequired()
|
||||
.HasMaxLength(1000)
|
||||
.HasColumnType("nvarchar(1000)");
|
||||
|
||||
b.Property<DateTime>("Date")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<bool>("Type")
|
||||
.HasColumnType("bit");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Messages");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Knots.Models.Role", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Libelle")
|
||||
.IsRequired()
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("nvarchar(50)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Roles");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Knots.Models.User", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Description")
|
||||
.HasMaxLength(200)
|
||||
.HasColumnType("nvarchar(200)");
|
||||
|
||||
b.Property<string>("Email")
|
||||
.IsRequired()
|
||||
.HasMaxLength(70)
|
||||
.HasColumnType("nvarchar(70)");
|
||||
|
||||
b.Property<string>("Password")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("ProfilePicture")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Tel")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Username")
|
||||
.IsRequired()
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("nvarchar(50)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Users");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
8
Knots/Models/Discussion.cs
Normal file
8
Knots/Models/Discussion.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Knots.Models;
|
||||
|
||||
public class Discussion
|
||||
{
|
||||
[Key] public int Id { get; set; }
|
||||
}
|
||||
12
Knots/Models/Group.cs
Normal file
12
Knots/Models/Group.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Net.Mime;
|
||||
|
||||
namespace Knots.Models;
|
||||
|
||||
public class Group
|
||||
{
|
||||
[Key] public int Id { get; set; }
|
||||
[Required, MaxLength(50)] public string? Nom { get; set; }
|
||||
[Required] public int NombreMembres { get; set; }
|
||||
public string? ProfilePicture { get; set; }
|
||||
}
|
||||
9
Knots/Models/Key.cs
Normal file
9
Knots/Models/Key.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Knots.Models;
|
||||
|
||||
public class Key
|
||||
{
|
||||
[Key] public int Id { get; set; }
|
||||
[Required, MaxLength(50)] public string? EnKey { get; set; }
|
||||
}
|
||||
11
Knots/Models/Message.cs
Normal file
11
Knots/Models/Message.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Knots.Models;
|
||||
|
||||
public class Message
|
||||
{
|
||||
[Key] public int Id { get; set; }
|
||||
[Required, MaxLength(1000)] public string? Contenu { get; set; }
|
||||
[Required] public DateTime Date { get; set; }
|
||||
[Required] public Boolean Type { get; set; }
|
||||
}
|
||||
9
Knots/Models/Role.cs
Normal file
9
Knots/Models/Role.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Knots.Models;
|
||||
|
||||
public class Role
|
||||
{
|
||||
public int Id { get; set; }
|
||||
[Required, MaxLength(50)] public string? Libelle { get; set; }
|
||||
}
|
||||
14
Knots/Models/User.cs
Normal file
14
Knots/Models/User.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Knots.Models;
|
||||
|
||||
public class User
|
||||
{
|
||||
public int Id { get; set; }
|
||||
[Required, MaxLength(50)] public string? Username { get; set; }
|
||||
[MaxLength(200)] public string? Description {get; set;}
|
||||
[Required, Length(12, 50)] public string? Password { get; set; }
|
||||
[Required, MaxLength(70)] public string? Email { get; set; }
|
||||
[Required, Length(10, 10)] public string? Tel { get; set; }
|
||||
public string? ProfilePicture { get; set; }
|
||||
}
|
||||
@@ -1,23 +1,36 @@
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
using Knots;
|
||||
using FastEndpoints;
|
||||
using FastEndpoints.Swagger;
|
||||
|
||||
// Add services to the container.
|
||||
WebApplicationBuilder builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
builder.Services.AddControllers();
|
||||
// Learn more about configuring OpenAPI at https://aka.ms/aspnet/openapi
|
||||
builder.Services.AddOpenApi();
|
||||
// On ajoute ici la configuration de la base de données
|
||||
builder.Services.AddDbContext<KnotsDbContext>();
|
||||
|
||||
var app = builder.Build();
|
||||
//On ajoute le CORS au code
|
||||
builder.Services.AddCors(options =>
|
||||
{ options.AddDefaultPolicy(policyBuilder =>
|
||||
{
|
||||
policyBuilder
|
||||
.WithOrigins("http://localhost:4200")
|
||||
.WithMethods("GET", "POST", "PUT", "PATCH", "DELETE")
|
||||
.AllowAnyHeader();
|
||||
});
|
||||
});
|
||||
|
||||
// Configure the HTTP request pipeline.
|
||||
if (app.Environment.IsDevelopment())
|
||||
{
|
||||
app.MapOpenApi();
|
||||
}
|
||||
// On construit l'application en lui donnant vie
|
||||
WebApplication app = builder.Build();
|
||||
app.UseAuthentication()
|
||||
.UseAuthorization()
|
||||
.UseFastEndpoints(options =>
|
||||
{
|
||||
options.Endpoints.RoutePrefix = "API";
|
||||
options.Endpoints.ShortNames = true;
|
||||
}
|
||||
).UseSwaggerGen();
|
||||
|
||||
app.UseHttpsRedirection();
|
||||
|
||||
app.UseAuthorization();
|
||||
|
||||
app.MapControllers();
|
||||
app.UseCors();
|
||||
|
||||
app.Run();
|
||||
15
Knots/Validators/Discussion/CreateDiscussionDtoValidator.cs
Normal file
15
Knots/Validators/Discussion/CreateDiscussionDtoValidator.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using FastEndpoints;
|
||||
using FluentValidation;
|
||||
using Knots.DTO.Discussion;
|
||||
|
||||
namespace Knots.Validators.Discussion;
|
||||
|
||||
public class CreateDiscussionDtoValidator : Validator<CreateDiscussionDto>
|
||||
{
|
||||
public CreateDiscussionDtoValidator()
|
||||
{
|
||||
RuleFor(x => x.Id)
|
||||
.NotEmpty()
|
||||
.WithMessage("Id is required");
|
||||
}
|
||||
}
|
||||
15
Knots/Validators/Discussion/DeleteDiscussionDtoValidator.cs
Normal file
15
Knots/Validators/Discussion/DeleteDiscussionDtoValidator.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using FastEndpoints;
|
||||
using FluentValidation;
|
||||
using Knots.DTO.Discussion;
|
||||
|
||||
namespace Knots.Validators.Discussion;
|
||||
|
||||
public class DeleteDiscussionDtoValidator : Validator<DeleteDiscussionDto>
|
||||
{
|
||||
public DeleteDiscussionDtoValidator()
|
||||
{
|
||||
RuleFor(x => x.Id)
|
||||
.NotEmpty()
|
||||
.WithMessage("Id is required");
|
||||
}
|
||||
}
|
||||
21
Knots/Validators/Group/CreateGroupDtoValidator.cs
Normal file
21
Knots/Validators/Group/CreateGroupDtoValidator.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using FastEndpoints;
|
||||
using FluentValidation;
|
||||
using Knots.DTO.Group;
|
||||
|
||||
namespace Knots.Validators.Group;
|
||||
|
||||
public class CreateGroupDtoValidator : Validator<CreateGroupDto>
|
||||
{
|
||||
public CreateGroupDtoValidator()
|
||||
{
|
||||
RuleFor(x => x.Nom)
|
||||
.NotEmpty()
|
||||
.WithMessage("You must enter a name for the group")
|
||||
.MaximumLength(50)
|
||||
.WithMessage("Maximum 50 character are required");
|
||||
|
||||
RuleFor(x => x.NombreMembres)
|
||||
.NotEmpty()
|
||||
.WithMessage("Members cannot be empty");
|
||||
}
|
||||
}
|
||||
15
Knots/Validators/Group/DeleteGroupDtoValidator.cs
Normal file
15
Knots/Validators/Group/DeleteGroupDtoValidator.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using FastEndpoints;
|
||||
using FluentValidation;
|
||||
using Knots.DTO.Group;
|
||||
|
||||
namespace Knots.Validators.Group;
|
||||
|
||||
public class DeleteGroupDtoValidator : Validator<DeleteGroupDto>
|
||||
{
|
||||
public DeleteGroupDtoValidator()
|
||||
{
|
||||
RuleFor(x => x.Id)
|
||||
.NotEmpty()
|
||||
.WithMessage("Id is required");
|
||||
}
|
||||
}
|
||||
15
Knots/Validators/Group/GetGroupDtoValidator.cs
Normal file
15
Knots/Validators/Group/GetGroupDtoValidator.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using FastEndpoints;
|
||||
using FluentValidation;
|
||||
using Knots.DTO.Group;
|
||||
|
||||
namespace Knots.Validators.Group;
|
||||
|
||||
public class GetGroupDtoValidator : Validator<GetGroupDto>
|
||||
{
|
||||
public GetGroupDtoValidator()
|
||||
{
|
||||
RuleFor(x => x.Id)
|
||||
.NotEmpty()
|
||||
.WithMessage("Id cannot be empty");
|
||||
}
|
||||
}
|
||||
9
Knots/Validators/Group/UpdateGroupDtoValidator.cs
Normal file
9
Knots/Validators/Group/UpdateGroupDtoValidator.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
using FastEndpoints;
|
||||
using Knots.DTO.Group;
|
||||
|
||||
namespace Knots.Validators.Group;
|
||||
|
||||
public class UpdateGroupDtoValidator : Validator<UpdateGroupDto>
|
||||
{
|
||||
|
||||
}
|
||||
6
Knots/Validators/Key/CreateKeyDtoValidator.cs
Normal file
6
Knots/Validators/Key/CreateKeyDtoValidator.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
namespace Knots.Validators.Key;
|
||||
|
||||
public class CreateKeyDtoValidator
|
||||
{
|
||||
|
||||
}
|
||||
6
Knots/Validators/Key/DeleteKeyDtoValidator.cs
Normal file
6
Knots/Validators/Key/DeleteKeyDtoValidator.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
namespace Knots.Validators.Key;
|
||||
|
||||
public class DeleteKeyDtoValidator
|
||||
{
|
||||
|
||||
}
|
||||
6
Knots/Validators/Key/GetKeyDtoValidator.cs
Normal file
6
Knots/Validators/Key/GetKeyDtoValidator.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
namespace Knots.Validators.Key;
|
||||
|
||||
public class GetKeyDtoValidator
|
||||
{
|
||||
|
||||
}
|
||||
6
Knots/Validators/Message/CreateMessageDtoValidator.cs
Normal file
6
Knots/Validators/Message/CreateMessageDtoValidator.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
namespace Knots.Validators.Message;
|
||||
|
||||
public class CreateMessageDtoValidator
|
||||
{
|
||||
|
||||
}
|
||||
6
Knots/Validators/Message/DeleteMessageDtoValidator.cs
Normal file
6
Knots/Validators/Message/DeleteMessageDtoValidator.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
namespace Knots.Validators.Message;
|
||||
|
||||
public class DeleteMessageDtoValidator
|
||||
{
|
||||
|
||||
}
|
||||
6
Knots/Validators/Message/GetMessageDtoValidator.cs
Normal file
6
Knots/Validators/Message/GetMessageDtoValidator.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
namespace Knots.Validators.Message;
|
||||
|
||||
public class GetMessageDtoValidator
|
||||
{
|
||||
|
||||
}
|
||||
6
Knots/Validators/Message/UpdateMessagesDto.cs
Normal file
6
Knots/Validators/Message/UpdateMessagesDto.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
namespace Knots.Validators.Message;
|
||||
|
||||
public class UpdateMessagesDto
|
||||
{
|
||||
|
||||
}
|
||||
6
Knots/Validators/Role/CreateRoleDtoValidator.cs
Normal file
6
Knots/Validators/Role/CreateRoleDtoValidator.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
namespace Knots.Validators.Role;
|
||||
|
||||
public class CreateRoleDtoValidator
|
||||
{
|
||||
|
||||
}
|
||||
6
Knots/Validators/Role/DeleteRoleDtoValidator.cs
Normal file
6
Knots/Validators/Role/DeleteRoleDtoValidator.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
namespace Knots.Validators.Role;
|
||||
|
||||
public class DeleteRoleDtoValidator
|
||||
{
|
||||
|
||||
}
|
||||
6
Knots/Validators/Role/GetRoleDtoValidator.cs
Normal file
6
Knots/Validators/Role/GetRoleDtoValidator.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
namespace Knots.Validators.Role;
|
||||
|
||||
public class GetRoleDtoValidator
|
||||
{
|
||||
|
||||
}
|
||||
6
Knots/Validators/User/CreateUserDtoValidator.cs
Normal file
6
Knots/Validators/User/CreateUserDtoValidator.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
namespace Knots.Validators.User;
|
||||
|
||||
public class CreateUserDtoValidator
|
||||
{
|
||||
|
||||
}
|
||||
6
Knots/Validators/User/DeleteUserDtoValidator.cs
Normal file
6
Knots/Validators/User/DeleteUserDtoValidator.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
namespace Knots.Validators.User;
|
||||
|
||||
public class DeleteUserDtoValidator
|
||||
{
|
||||
|
||||
}
|
||||
6
Knots/Validators/User/GetUserDtoValidator.cs
Normal file
6
Knots/Validators/User/GetUserDtoValidator.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
namespace Knots.Validators.User;
|
||||
|
||||
public class GetUserDtoValidator
|
||||
{
|
||||
|
||||
}
|
||||
6
Knots/Validators/User/UpdateUserDtoValidator.cs
Normal file
6
Knots/Validators/User/UpdateUserDtoValidator.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
namespace Knots.Validators.User;
|
||||
|
||||
public class UpdateUserDtoValidator
|
||||
{
|
||||
|
||||
}
|
||||
BIN
Knots/bin/Debug/net8.0/Azure.Core.dll
Executable file
BIN
Knots/bin/Debug/net8.0/Azure.Core.dll
Executable file
Binary file not shown.
BIN
Knots/bin/Debug/net8.0/Azure.Identity.dll
Executable file
BIN
Knots/bin/Debug/net8.0/Azure.Identity.dll
Executable file
Binary file not shown.
BIN
Knots/bin/Debug/net8.0/FastEndpoints.Attributes.dll
Executable file
BIN
Knots/bin/Debug/net8.0/FastEndpoints.Attributes.dll
Executable file
Binary file not shown.
BIN
Knots/bin/Debug/net8.0/FastEndpoints.Core.dll
Executable file
BIN
Knots/bin/Debug/net8.0/FastEndpoints.Core.dll
Executable file
Binary file not shown.
BIN
Knots/bin/Debug/net8.0/FastEndpoints.JobQueues.dll
Executable file
BIN
Knots/bin/Debug/net8.0/FastEndpoints.JobQueues.dll
Executable file
Binary file not shown.
BIN
Knots/bin/Debug/net8.0/FastEndpoints.Messaging.Core.dll
Executable file
BIN
Knots/bin/Debug/net8.0/FastEndpoints.Messaging.Core.dll
Executable file
Binary file not shown.
BIN
Knots/bin/Debug/net8.0/FastEndpoints.Messaging.dll
Executable file
BIN
Knots/bin/Debug/net8.0/FastEndpoints.Messaging.dll
Executable file
Binary file not shown.
BIN
Knots/bin/Debug/net8.0/FastEndpoints.Swagger.dll
Executable file
BIN
Knots/bin/Debug/net8.0/FastEndpoints.Swagger.dll
Executable file
Binary file not shown.
BIN
Knots/bin/Debug/net8.0/FastEndpoints.dll
Executable file
BIN
Knots/bin/Debug/net8.0/FastEndpoints.dll
Executable file
Binary file not shown.
BIN
Knots/bin/Debug/net8.0/FluentValidation.dll
Executable file
BIN
Knots/bin/Debug/net8.0/FluentValidation.dll
Executable file
Binary file not shown.
BIN
Knots/bin/Debug/net8.0/Humanizer.dll
Executable file
BIN
Knots/bin/Debug/net8.0/Humanizer.dll
Executable file
Binary file not shown.
BIN
Knots/bin/Debug/net8.0/Knots
Executable file
BIN
Knots/bin/Debug/net8.0/Knots
Executable file
Binary file not shown.
1955
Knots/bin/Debug/net8.0/Knots.deps.json
Normal file
1955
Knots/bin/Debug/net8.0/Knots.deps.json
Normal file
File diff suppressed because it is too large
Load Diff
BIN
Knots/bin/Debug/net8.0/Knots.dll
Normal file
BIN
Knots/bin/Debug/net8.0/Knots.dll
Normal file
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user