Edited database to add posts on the app
This commit is contained in:
@@ -15,6 +15,7 @@ public class BeReadyDbContext : DbContext
|
||||
public DbSet<UserFriend> UserFriends { get; set; }
|
||||
public DbSet<UserGroup> UserGroups { get; set; }
|
||||
public DbSet<UserRandomChallenge> UserRandomChallenges { get; set; }
|
||||
public DbSet<Post> Posts { get; set; }
|
||||
|
||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||
{
|
||||
|
||||
@@ -40,7 +40,6 @@ public class AddUserToGroupEndpoint(UserService userService, UserGroupsRepositor
|
||||
|
||||
userGroup = mapper.Map<UserGroup>(req);
|
||||
userGroup.Grade = "Member";
|
||||
userGroup.Score = 0;
|
||||
|
||||
await userGroupsRepository.AddAsync(userGroup, ct);
|
||||
await Send.NoContentAsync(ct);
|
||||
|
||||
@@ -26,7 +26,6 @@ public class CreateGroupEndpoint(
|
||||
|
||||
Group group = new();
|
||||
mapper.Map(req, group);
|
||||
group.IsFinished = false;
|
||||
group.CreationDate = DateTime.Now;
|
||||
group.UserGroups = [];
|
||||
|
||||
@@ -41,8 +40,7 @@ public class CreateGroupEndpoint(
|
||||
{
|
||||
UserId = user.UserId,
|
||||
GroupId = group.Id,
|
||||
Grade = "Member",
|
||||
Score = 0
|
||||
Grade = "Member"
|
||||
};
|
||||
group.UserGroups?.Add(userGroup);
|
||||
}
|
||||
@@ -51,8 +49,7 @@ public class CreateGroupEndpoint(
|
||||
{
|
||||
UserId = userId,
|
||||
GroupId = group.Id,
|
||||
Grade = "Admin",
|
||||
Score = 0
|
||||
Grade = "Admin"
|
||||
};
|
||||
group.UserGroups?.Add(userGroup);
|
||||
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
using BeReadyBackend.DTO.Groups;
|
||||
using BeReadyBackend.Repositories;
|
||||
using BeReadyBackend.Specifications.Groups;
|
||||
using FastEndpoints;
|
||||
using Group = BeReadyBackend.Models.Group;
|
||||
|
||||
namespace BeReadyBackend.Endpoints.Groups;
|
||||
|
||||
public class GroupProofRequest
|
||||
{
|
||||
public int Id { get; set; }
|
||||
}
|
||||
|
||||
public class GetAllProofsEndpoint(UserGroupsRepository userGroupsRepository, GroupsRepository groupsRepository) : Endpoint<GroupProofRequest, List<GetProofDto>>
|
||||
{
|
||||
public override void Configure()
|
||||
{
|
||||
Get("/Groups/{@Id}/Proofs/", x => new { x.Id });
|
||||
}
|
||||
|
||||
public override async Task HandleAsync(GroupProofRequest req, CancellationToken ct)
|
||||
{
|
||||
Group? group = await groupsRepository.SingleOrDefaultAsync(new GetGroupByIdSpec(req.Id), ct);
|
||||
if (group is null)
|
||||
{
|
||||
await Send.NotFoundAsync(ct);
|
||||
return;
|
||||
}
|
||||
|
||||
if (group.StartedVote != null && group.StartedVote.Value.AddHours(group.VoteDuration) < DateTime.Now)
|
||||
{
|
||||
await Send.StringAsync("Les votes ne sont pas fini", 400, cancellation: ct);
|
||||
return;
|
||||
}
|
||||
|
||||
List<GetProofDto> usersGroup = await userGroupsRepository.ProjectToListAsync<GetProofDto>(new GetUserGroupDetailsByIdSpec(req.Id), ct);
|
||||
await Send.OkAsync(usersGroup, ct);
|
||||
}
|
||||
}
|
||||
@@ -1,61 +0,0 @@
|
||||
using BeReadyBackend.DTO.Groups;
|
||||
using BeReadyBackend.Models;
|
||||
using BeReadyBackend.Repositories;
|
||||
using BeReadyBackend.Specifications.Groups;
|
||||
using BeReadyBackend.Specifications.Users;
|
||||
using FastEndpoints;
|
||||
using Group = BeReadyBackend.Models.Group;
|
||||
|
||||
namespace BeReadyBackend.Endpoints.Groups;
|
||||
|
||||
public class GroupRankingRequest
|
||||
{
|
||||
public int Id { get; set; }
|
||||
}
|
||||
|
||||
public class GetGroupRankingEndpoint(
|
||||
GroupsRepository groupsRepository,
|
||||
UsersRepository usersRepository,
|
||||
UserGroupsRepository userGroupsRepository)
|
||||
: Endpoint<GroupRankingRequest, List<GetGroupRankingDto>>
|
||||
{
|
||||
public override void Configure()
|
||||
{
|
||||
Get("/Groups/{@Id}/GroupRank", x => new { x.Id });
|
||||
}
|
||||
|
||||
public override async Task HandleAsync(GroupRankingRequest req, CancellationToken ct)
|
||||
{
|
||||
Group? group = await groupsRepository.SingleOrDefaultAsync(new GetGroupByIdSpec(req.Id), ct);
|
||||
if (group is null)
|
||||
{
|
||||
await Send.NotFoundAsync(ct);
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (UserGroup member in group.UserGroups!)
|
||||
{
|
||||
if (member.Proof is null) member.Score -= 2;
|
||||
|
||||
if (!member.VotedProofId.HasValue) continue;
|
||||
User? votedUser = await usersRepository.SingleOrDefaultAsync(new GetUserByIdSpec(member.VotedProofId.Value), ct);
|
||||
if (votedUser is not null) votedUser.Score++;
|
||||
}
|
||||
|
||||
await usersRepository.SaveChangesAsync(ct);
|
||||
await userGroupsRepository.SaveChangesAsync(ct);
|
||||
|
||||
List<GetGroupRankingDto> groupScore = await userGroupsRepository.ProjectToListAsync<GetGroupRankingDto>(new GetGroupRankSpec(req.Id), ct);
|
||||
|
||||
int[] points = [5, 3, 1];
|
||||
for (int i = 0; i < groupScore.Count && i < 3; i++)
|
||||
{
|
||||
User? user = await usersRepository.SingleOrDefaultAsync(new GetUserByIdSpec(groupScore[i].UserId), ct);
|
||||
if (user != null) user.Score += points[i];
|
||||
}
|
||||
|
||||
await usersRepository.SaveChangesAsync(ct);
|
||||
|
||||
await Send.OkAsync(groupScore, ct);
|
||||
}
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
using BeReadyBackend.Repositories;
|
||||
using BeReadyBackend.Specifications.Groups;
|
||||
using FastEndpoints;
|
||||
using Group = BeReadyBackend.Models.Group;
|
||||
|
||||
namespace BeReadyBackend.Endpoints.Groups;
|
||||
|
||||
public class StatusRequest
|
||||
{
|
||||
public int GroupId { get; set; }
|
||||
}
|
||||
|
||||
public class PatchGroupStatusEndpoint(GroupsRepository groupsRepository) : Endpoint<StatusRequest>
|
||||
{
|
||||
public override void Configure()
|
||||
{
|
||||
Patch("/Groups/{@GroupId}/Status/", x => new { x.GroupId });
|
||||
}
|
||||
|
||||
public override async Task HandleAsync(StatusRequest req, CancellationToken ct)
|
||||
{
|
||||
Group? group = await groupsRepository.SingleOrDefaultAsync(new GetGroupByIdSpec(req.GroupId), ct);
|
||||
|
||||
if (group is null)
|
||||
{
|
||||
await Send.NotFoundAsync(ct);
|
||||
return;
|
||||
}
|
||||
|
||||
group.IsFinished = true;
|
||||
await groupsRepository.SaveChangesAsync(ct);
|
||||
await Send.NoContentAsync(ct);
|
||||
}
|
||||
}
|
||||
@@ -1,65 +0,0 @@
|
||||
using BeReadyBackend.Hubs;
|
||||
using BeReadyBackend.Models;
|
||||
using BeReadyBackend.Repositories;
|
||||
using BeReadyBackend.Services;
|
||||
using BeReadyBackend.Specifications.Groups;
|
||||
using FastEndpoints;
|
||||
using Microsoft.AspNetCore.SignalR;
|
||||
|
||||
namespace BeReadyBackend.Endpoints.Groups;
|
||||
|
||||
public class UserProofRequest
|
||||
{
|
||||
public int GroupId { get; set; }
|
||||
public IFormFile? Proof { get; set; }
|
||||
}
|
||||
|
||||
public class PatchGroupUserProofEndpoint(UserGroupsRepository userGroupsRepository, UserService userService, IHubContext<GroupHub> hubContext) : Endpoint<UserProofRequest>
|
||||
{
|
||||
public override void Configure()
|
||||
{
|
||||
Patch("/Groups/{@GroupId}/Users/Proof/", x => new { x.GroupId });
|
||||
}
|
||||
|
||||
public override async Task HandleAsync(UserProofRequest req, CancellationToken ct)
|
||||
{
|
||||
int userId = userService.GetUserIdFromToken();
|
||||
UserGroup? member = await userGroupsRepository.SingleOrDefaultAsync(new GetUserInGroupByIdsSpec(req.GroupId, userId), ct);
|
||||
|
||||
if (member is null)
|
||||
{
|
||||
await Send.NotFoundAsync(ct);
|
||||
return;
|
||||
}
|
||||
|
||||
if (member.Proof is not null)
|
||||
{
|
||||
await Send.StringAsync("Vous avez déjà déposé une photo", 400, cancellation: ct);
|
||||
return;
|
||||
}
|
||||
|
||||
if (member.Group != null && member.Group.IsFinished)
|
||||
{
|
||||
await Send.StringAsync("Ce défi est terminé", 400, cancellation: ct);
|
||||
return;
|
||||
}
|
||||
|
||||
if (req.Proof == null || req.Proof.Length == 0)
|
||||
{
|
||||
await Send.StringAsync("Photo non fournie", 400, cancellation: ct);
|
||||
return;
|
||||
}
|
||||
|
||||
// Encodage base64
|
||||
using MemoryStream memoryStream = new();
|
||||
await req.Proof.CopyToAsync(memoryStream, ct);
|
||||
byte[] proofBytes = memoryStream.ToArray();
|
||||
|
||||
member.Proof = Convert.ToBase64String(proofBytes);
|
||||
await userGroupsRepository.SaveChangesAsync(ct);
|
||||
|
||||
await hubContext.Clients.Group($"group-{req.GroupId}").SendAsync("ReceiveProof", member.Proof, cancellationToken: ct);
|
||||
|
||||
await Send.NoContentAsync(ct);
|
||||
}
|
||||
}
|
||||
@@ -1,55 +0,0 @@
|
||||
using BeReadyBackend.Models;
|
||||
using BeReadyBackend.Repositories;
|
||||
using BeReadyBackend.Services;
|
||||
using BeReadyBackend.Specifications.Groups;
|
||||
using FastEndpoints;
|
||||
|
||||
namespace BeReadyBackend.Endpoints.Groups;
|
||||
|
||||
public class UserVoteRequest
|
||||
{
|
||||
public int GroupId { get; set; }
|
||||
public int VotedProofId { get; set; }
|
||||
}
|
||||
|
||||
public class PatchVoteEndpoint(UserGroupsRepository userGroupsRepository, UserService userService) : Endpoint<UserVoteRequest>
|
||||
{
|
||||
public override void Configure()
|
||||
{
|
||||
Patch("/Groups/{@GroupId}/Users/Vote/", x => new { x.GroupId });
|
||||
}
|
||||
|
||||
public override async Task HandleAsync(UserVoteRequest req, CancellationToken ct)
|
||||
{
|
||||
int userId = userService.GetUserIdFromToken();
|
||||
UserGroup? member = await userGroupsRepository.SingleOrDefaultAsync(new GetUserInGroupByIdsSpec(req.GroupId, userId), ct);
|
||||
|
||||
if (member is null)
|
||||
{
|
||||
await Send.NotFoundAsync(ct);
|
||||
return;
|
||||
}
|
||||
|
||||
if (member.VotedProofId is not null)
|
||||
{
|
||||
await Send.StringAsync("Vous ne pouvez pas voter plusieurs fois", 400, cancellation: ct);
|
||||
return;
|
||||
}
|
||||
|
||||
if (member.Group!.StartedVote is not null && member.Group.StartedVote.Value.AddHours(member.Group.VoteDuration) < DateTime.Now)
|
||||
{
|
||||
await Send.StringAsync("Le vote est terminé", 400, cancellation: ct);
|
||||
return;
|
||||
}
|
||||
|
||||
if (member.Group!.StartedVote is null)
|
||||
{
|
||||
await Send.StringAsync("Le vote n'a pas commencé", 400, cancellation: ct);
|
||||
return;
|
||||
}
|
||||
|
||||
member.VotedProofId = req.VotedProofId;
|
||||
await userGroupsRepository.SaveChangesAsync(ct);
|
||||
await Send.NoContentAsync(ct);
|
||||
}
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
using BeReadyBackend.Hubs;
|
||||
using BeReadyBackend.Models;
|
||||
using BeReadyBackend.Repositories;
|
||||
using BeReadyBackend.Services;
|
||||
using BeReadyBackend.Specifications.Groups;
|
||||
using FastEndpoints;
|
||||
using Microsoft.AspNetCore.SignalR;
|
||||
using Group = BeReadyBackend.Models.Group;
|
||||
|
||||
namespace BeReadyBackend.Endpoints.Groups;
|
||||
|
||||
public class GroupVoteRequest
|
||||
{
|
||||
public int Id { get; set; }
|
||||
}
|
||||
|
||||
public class StartVoteEndpoint(UserGroupsRepository userGroupsRepository, GroupsRepository groupsRepository, UserService userService, IHubContext<GroupHub> hubContext)
|
||||
: Endpoint<GroupVoteRequest>
|
||||
{
|
||||
public override void Configure()
|
||||
{
|
||||
Post("/Groups/{@Id}/Vote/", x => new { x.Id });
|
||||
}
|
||||
|
||||
public override async Task HandleAsync(GroupVoteRequest req, CancellationToken ct)
|
||||
{
|
||||
Group? group = await groupsRepository.SingleOrDefaultAsync(new GetGroupByIdSpec(req.Id), ct);
|
||||
|
||||
if (group is null)
|
||||
{
|
||||
await Send.NotFoundAsync(ct);
|
||||
return;
|
||||
}
|
||||
|
||||
if (group.IsFinished)
|
||||
{
|
||||
await Send.StringAsync("Le défi est terminé", 400, cancellation: ct);
|
||||
return;
|
||||
}
|
||||
|
||||
if (group.CreationDate.AddHours(group.Duration) > DateTime.Now || !group.IsFinished)
|
||||
{
|
||||
await Send.StringAsync("Le défi n'est pas encore terminé", 400, cancellation: ct);
|
||||
return;
|
||||
}
|
||||
|
||||
group.StartedVote = DateTime.Now;
|
||||
await groupsRepository.SaveChangesAsync(ct);
|
||||
|
||||
await hubContext.Clients.Group($"group-{req.Id}").SendAsync("StartVote", cancellationToken: ct);
|
||||
await Send.NoContentAsync(ct);
|
||||
}
|
||||
}
|
||||
@@ -32,12 +32,6 @@ public class SendMessageEndpoint(
|
||||
return;
|
||||
}
|
||||
|
||||
if (group.IsFinished)
|
||||
{
|
||||
await Send.StringAsync("Le groupe est fermé", 400, cancellation: ct);
|
||||
return;
|
||||
}
|
||||
|
||||
Message message = new();
|
||||
mapper.Map(req, message);
|
||||
message.UserId = userService.GetUserIdFromToken();
|
||||
|
||||
@@ -36,7 +36,7 @@ public class PatchProofEndpoint(
|
||||
return;
|
||||
}
|
||||
|
||||
if (randomChallenge.GeneratedAt != null && DateTime.Now > randomChallenge.GeneratedAt.Value.AddHours(randomChallenge.Duration))
|
||||
if (randomChallenge.GeneratedAt != null && DateOnly.FromDateTime(DateTime.Now) > DateOnly.FromDateTime(randomChallenge.GeneratedAt.Value))
|
||||
{
|
||||
await Send.StringAsync("Le défi est terminé", 400, cancellation: ct);
|
||||
return;
|
||||
@@ -76,8 +76,7 @@ public class PatchProofEndpoint(
|
||||
|
||||
userRandomChallenge.Proof = Convert.ToBase64String(proofBytes);
|
||||
|
||||
user.Score++; // 1pts bonus
|
||||
user.TotalBonusChallenge++; // +1 challenge bonus de fait
|
||||
user.TotalChallenge++; // +1 challenge bonus de fait
|
||||
|
||||
await usersRepository.SaveChangesAsync(ct);
|
||||
await userRandomChallengesRepository.SaveChangesAsync(ct);
|
||||
|
||||
@@ -29,15 +29,8 @@ public class CreateUserEndpoint(UsersRepository usersRepository, AutoMapper.IMap
|
||||
|
||||
user = mapper.Map<User>(req);
|
||||
|
||||
user.CreationDate = DateTime.Now;
|
||||
user.Salt = salt;
|
||||
user.Password = BCrypt.Net.BCrypt.HashPassword(req.Password + salt);
|
||||
user.Score = 0;
|
||||
user.TotalWin = 0;
|
||||
user.TotalChallenge = 0;
|
||||
user.TotalPodium = 0;
|
||||
user.TotalBonusChallenge = 0;
|
||||
user.Series = 0;
|
||||
|
||||
await usersRepository.AddAsync(user, ct);
|
||||
await Send.NoContentAsync(ct);
|
||||
|
||||
@@ -37,14 +37,6 @@ public class GetAllUserProofsEndpoint(UsersRepository usersRepository, UserServi
|
||||
})
|
||||
);
|
||||
|
||||
if (user.UserGroups is not null)
|
||||
proofs.AddRange(
|
||||
user.UserGroups.Select(x => new GetUserProofDto
|
||||
{
|
||||
Proof = x.Proof
|
||||
})
|
||||
);
|
||||
|
||||
await Send.OkAsync(proofs, ct);
|
||||
}
|
||||
}
|
||||
@@ -37,32 +37,24 @@ public class EntityToDtoMappings : Profile
|
||||
CreateMap<RandomChallenge, GetUserChallengeDto>()
|
||||
.ForMember(dest => dest.ChallengeTitle, opt => opt.MapFrom(src => src.Label))
|
||||
.ForMember(dest => dest.ChallengeDescription, opt => opt.MapFrom(src => src.Libelle))
|
||||
.ForMember(dest => dest.ChallengeDuration, opt => opt.MapFrom(src => src.Duration))
|
||||
.ForMember(dest => dest.ChallengeStartDate, opt => opt.MapFrom(src => DateOnly.FromDateTime(src.GeneratedAt!.Value)));
|
||||
|
||||
CreateMap<Group, GetUserChallengeDto>()
|
||||
.ForMember(dest => dest.ChallengeTitle, opt => opt.MapFrom(src => src.Title))
|
||||
.ForMember(dest => dest.ChallengeDescription, opt => opt.MapFrom(src => src.Description))
|
||||
.ForMember(dest => dest.ChallengeDuration, opt => opt.MapFrom(src => src.Duration))
|
||||
.ForMember(dest => dest.ChallengeStartDate, opt => opt.MapFrom(src => DateOnly.FromDateTime(src.CreationDate)));
|
||||
|
||||
|
||||
CreateMap<UserFriend, GetFriendDto>()
|
||||
.ForMember(dest => dest.Username, opt => opt.MapFrom(src => src.Friend!.Username))
|
||||
.ForMember(dest => dest.Score, opt => opt.MapFrom(src => src.Friend!.Score));
|
||||
.ForMember(dest => dest.Score, opt => opt.MapFrom(src => src.Friend!.TotalLikes));
|
||||
|
||||
CreateMap<UserFriend, GetFriendRequestDto>()
|
||||
.ForMember(dest => dest.Username, opt => opt.MapFrom(src => src.User!.Username))
|
||||
.ForMember(dest => dest.Score, opt => opt.MapFrom(src => src.User!.Score));
|
||||
.ForMember(dest => dest.Score, opt => opt.MapFrom(src => src.User!.TotalLikes));
|
||||
|
||||
CreateMap<UserGroup, GetUserGroupDto>()
|
||||
.ForMember(dest => dest.Id, opt => opt.MapFrom(src => src.UserId))
|
||||
.ForMember(dest => dest.Username, opt => opt.MapFrom(src => src.User!.Username))
|
||||
.ForMember(dest => dest.Score, opt => opt.MapFrom(src => src.User!.Score));
|
||||
.ForMember(dest => dest.Score, opt => opt.MapFrom(src => src.User!.TotalLikes));
|
||||
|
||||
CreateMap<UserGroup, GetGroupDto>()
|
||||
.ForMember(dest => dest.Id, opt => opt.MapFrom(src => src.GroupId))
|
||||
.ForMember(dest => dest.Label, opt => opt.MapFrom(src => src.Group!.Label))
|
||||
.ForMember(dest => dest.IsFinished, opt => opt.MapFrom(src => src.Group!.IsFinished));
|
||||
.ForMember(dest => dest.Label, opt => opt.MapFrom(src => src.Group!.Label));
|
||||
|
||||
CreateMap<Group, GetGroupDetailsDto>()
|
||||
.ForMember(dest => dest.Users, opt => opt.MapFrom(src => src.UserGroups))
|
||||
|
||||
@@ -0,0 +1,450 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using BeReadyBackend;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace BeReadyBackend.Migrations
|
||||
{
|
||||
[DbContext(typeof(BeReadyDbContext))]
|
||||
[Migration("20260421075849_AddedPostEntity")]
|
||||
partial class AddedPostEntity
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "8.0.20")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||
|
||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("BeReadyBackend.Models.Achievement", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Description")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Label")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Achievements");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeReadyBackend.Models.Designation", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Label")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Designations");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeReadyBackend.Models.Group", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<DateTime>("CreationDate")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<string>("Label")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Groups");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeReadyBackend.Models.Message", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("GroupId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("Libelle")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<DateTime>("SendDate")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<int>("UserId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("GroupId");
|
||||
|
||||
b.HasIndex("UserId");
|
||||
|
||||
b.ToTable("Messages");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeReadyBackend.Models.Posts", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<DateTime>("CreationDate")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<string>("Libelle")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("Likes")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("UserId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("UserId");
|
||||
|
||||
b.ToTable("Posts");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeReadyBackend.Models.RandomChallenge", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<DateTime?>("GeneratedAt")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<bool>("IsAlreadyPast")
|
||||
.HasColumnType("bit");
|
||||
|
||||
b.Property<string>("Label")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Libelle")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("RandomChallenges");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeReadyBackend.Models.User", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<DateTime>("CreationDate")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<int?>("DesignationId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("Email")
|
||||
.IsRequired()
|
||||
.HasMaxLength(100)
|
||||
.HasColumnType("nvarchar(100)");
|
||||
|
||||
b.Property<string>("FirstName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Password")
|
||||
.IsRequired()
|
||||
.HasMaxLength(60)
|
||||
.HasColumnType("nvarchar(60)");
|
||||
|
||||
b.Property<string>("Salt")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("Series")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("TotalChallenge")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("TotalLikes")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("Username")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("DesignationId");
|
||||
|
||||
b.ToTable("Users");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeReadyBackend.Models.UserAchievement", b =>
|
||||
{
|
||||
b.Property<int>("UserId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("AchievementId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("UserId", "AchievementId");
|
||||
|
||||
b.HasIndex("AchievementId");
|
||||
|
||||
b.ToTable("UserAchievements");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeReadyBackend.Models.UserFriend", b =>
|
||||
{
|
||||
b.Property<int>("UserId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("FriendId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<bool>("IsAccepted")
|
||||
.HasColumnType("bit");
|
||||
|
||||
b.HasKey("UserId", "FriendId");
|
||||
|
||||
b.HasIndex("FriendId");
|
||||
|
||||
b.ToTable("UserFriends");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeReadyBackend.Models.UserGroup", b =>
|
||||
{
|
||||
b.Property<int>("UserId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("GroupId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("Grade")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("UserId", "GroupId");
|
||||
|
||||
b.HasIndex("GroupId");
|
||||
|
||||
b.ToTable("UserGroups");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeReadyBackend.Models.UserRandomChallenge", b =>
|
||||
{
|
||||
b.Property<int>("UserId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("RandomChallengeId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("Proof")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("UserId", "RandomChallengeId");
|
||||
|
||||
b.HasIndex("RandomChallengeId");
|
||||
|
||||
b.ToTable("UserRandomChallenges");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeReadyBackend.Models.Message", b =>
|
||||
{
|
||||
b.HasOne("BeReadyBackend.Models.Group", "Group")
|
||||
.WithMany("Messages")
|
||||
.HasForeignKey("GroupId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("BeReadyBackend.Models.User", "User")
|
||||
.WithMany("Messages")
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Group");
|
||||
|
||||
b.Navigation("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeReadyBackend.Models.Posts", b =>
|
||||
{
|
||||
b.HasOne("BeReadyBackend.Models.User", "User")
|
||||
.WithMany("Posts")
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeReadyBackend.Models.User", b =>
|
||||
{
|
||||
b.HasOne("BeReadyBackend.Models.Designation", "Designation")
|
||||
.WithMany("Users")
|
||||
.HasForeignKey("DesignationId");
|
||||
|
||||
b.Navigation("Designation");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeReadyBackend.Models.UserAchievement", b =>
|
||||
{
|
||||
b.HasOne("BeReadyBackend.Models.Achievement", "Achievement")
|
||||
.WithMany("UserAchievements")
|
||||
.HasForeignKey("AchievementId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("BeReadyBackend.Models.User", "User")
|
||||
.WithMany("UserAchievements")
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Achievement");
|
||||
|
||||
b.Navigation("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeReadyBackend.Models.UserFriend", b =>
|
||||
{
|
||||
b.HasOne("BeReadyBackend.Models.User", "Friend")
|
||||
.WithMany()
|
||||
.HasForeignKey("FriendId")
|
||||
.OnDelete(DeleteBehavior.Restrict)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("BeReadyBackend.Models.User", "User")
|
||||
.WithMany("UserFriends")
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Restrict)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Friend");
|
||||
|
||||
b.Navigation("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeReadyBackend.Models.UserGroup", b =>
|
||||
{
|
||||
b.HasOne("BeReadyBackend.Models.Group", "Group")
|
||||
.WithMany("UserGroups")
|
||||
.HasForeignKey("GroupId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("BeReadyBackend.Models.User", "User")
|
||||
.WithMany("UserGroups")
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Group");
|
||||
|
||||
b.Navigation("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeReadyBackend.Models.UserRandomChallenge", b =>
|
||||
{
|
||||
b.HasOne("BeReadyBackend.Models.RandomChallenge", "RandomChallenge")
|
||||
.WithMany("UserRandomChallenges")
|
||||
.HasForeignKey("RandomChallengeId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("BeReadyBackend.Models.User", "User")
|
||||
.WithMany("UserRandomChallenges")
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("RandomChallenge");
|
||||
|
||||
b.Navigation("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeReadyBackend.Models.Achievement", b =>
|
||||
{
|
||||
b.Navigation("UserAchievements");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeReadyBackend.Models.Designation", b =>
|
||||
{
|
||||
b.Navigation("Users");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeReadyBackend.Models.Group", b =>
|
||||
{
|
||||
b.Navigation("Messages");
|
||||
|
||||
b.Navigation("UserGroups");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeReadyBackend.Models.RandomChallenge", b =>
|
||||
{
|
||||
b.Navigation("UserRandomChallenges");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeReadyBackend.Models.User", b =>
|
||||
{
|
||||
b.Navigation("Messages");
|
||||
|
||||
b.Navigation("Posts");
|
||||
|
||||
b.Navigation("UserAchievements");
|
||||
|
||||
b.Navigation("UserFriends");
|
||||
|
||||
b.Navigation("UserGroups");
|
||||
|
||||
b.Navigation("UserRandomChallenges");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,199 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace BeReadyBackend.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class AddedPostEntity : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "Score",
|
||||
table: "Users");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "TotalBonusChallenge",
|
||||
table: "Users");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "TotalPodium",
|
||||
table: "Users");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "Proof",
|
||||
table: "UserGroups");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "Score",
|
||||
table: "UserGroups");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "VotedProofId",
|
||||
table: "UserGroups");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "Duration",
|
||||
table: "RandomChallenges");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "Description",
|
||||
table: "Groups");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "Duration",
|
||||
table: "Groups");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "IsFinished",
|
||||
table: "Groups");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "StartedVote",
|
||||
table: "Groups");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "Title",
|
||||
table: "Groups");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "VoteDuration",
|
||||
table: "Groups");
|
||||
|
||||
migrationBuilder.RenameColumn(
|
||||
name: "TotalWin",
|
||||
table: "Users",
|
||||
newName: "TotalLikes");
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Posts",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
Libelle = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
||||
CreationDate = table.Column<DateTime>(type: "datetime2", nullable: false),
|
||||
Likes = table.Column<int>(type: "int", nullable: false),
|
||||
UserId = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Posts", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Posts_Users_UserId",
|
||||
column: x => x.UserId,
|
||||
principalTable: "Users",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Posts_UserId",
|
||||
table: "Posts",
|
||||
column: "UserId");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "Posts");
|
||||
|
||||
migrationBuilder.RenameColumn(
|
||||
name: "TotalLikes",
|
||||
table: "Users",
|
||||
newName: "TotalWin");
|
||||
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "Score",
|
||||
table: "Users",
|
||||
type: "int",
|
||||
nullable: false,
|
||||
defaultValue: 0);
|
||||
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "TotalBonusChallenge",
|
||||
table: "Users",
|
||||
type: "int",
|
||||
nullable: false,
|
||||
defaultValue: 0);
|
||||
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "TotalPodium",
|
||||
table: "Users",
|
||||
type: "int",
|
||||
nullable: false,
|
||||
defaultValue: 0);
|
||||
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "Proof",
|
||||
table: "UserGroups",
|
||||
type: "nvarchar(max)",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "Score",
|
||||
table: "UserGroups",
|
||||
type: "int",
|
||||
nullable: false,
|
||||
defaultValue: 0);
|
||||
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "VotedProofId",
|
||||
table: "UserGroups",
|
||||
type: "int",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "Duration",
|
||||
table: "RandomChallenges",
|
||||
type: "int",
|
||||
nullable: false,
|
||||
defaultValue: 0);
|
||||
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "Description",
|
||||
table: "Groups",
|
||||
type: "nvarchar(max)",
|
||||
nullable: false,
|
||||
defaultValue: "");
|
||||
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "Duration",
|
||||
table: "Groups",
|
||||
type: "int",
|
||||
nullable: false,
|
||||
defaultValue: 0);
|
||||
|
||||
migrationBuilder.AddColumn<bool>(
|
||||
name: "IsFinished",
|
||||
table: "Groups",
|
||||
type: "bit",
|
||||
nullable: false,
|
||||
defaultValue: false);
|
||||
|
||||
migrationBuilder.AddColumn<DateTime>(
|
||||
name: "StartedVote",
|
||||
table: "Groups",
|
||||
type: "datetime2",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "Title",
|
||||
table: "Groups",
|
||||
type: "nvarchar(max)",
|
||||
nullable: false,
|
||||
defaultValue: "");
|
||||
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "VoteDuration",
|
||||
table: "Groups",
|
||||
type: "int",
|
||||
nullable: false,
|
||||
defaultValue: 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,450 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using BeReadyBackend;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace BeReadyBackend.Migrations
|
||||
{
|
||||
[DbContext(typeof(BeReadyDbContext))]
|
||||
[Migration("20260421080209_EditedDatabase")]
|
||||
partial class EditedDatabase
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "8.0.20")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||
|
||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("BeReadyBackend.Models.Achievement", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Description")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Label")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Achievements");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeReadyBackend.Models.Designation", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Label")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Designations");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeReadyBackend.Models.Group", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<DateTime>("CreationDate")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<string>("Label")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Groups");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeReadyBackend.Models.Message", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("GroupId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("Libelle")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<DateTime>("SendDate")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<int>("UserId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("GroupId");
|
||||
|
||||
b.HasIndex("UserId");
|
||||
|
||||
b.ToTable("Messages");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeReadyBackend.Models.Post", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<DateTime>("CreationDate")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<string>("Libelle")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("Likes")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("UserId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("UserId");
|
||||
|
||||
b.ToTable("Posts");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeReadyBackend.Models.RandomChallenge", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<DateTime?>("GeneratedAt")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<bool>("IsAlreadyPast")
|
||||
.HasColumnType("bit");
|
||||
|
||||
b.Property<string>("Label")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Libelle")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("RandomChallenges");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeReadyBackend.Models.User", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<DateTime>("CreationDate")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<int?>("DesignationId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("Email")
|
||||
.IsRequired()
|
||||
.HasMaxLength(100)
|
||||
.HasColumnType("nvarchar(100)");
|
||||
|
||||
b.Property<string>("FirstName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Password")
|
||||
.IsRequired()
|
||||
.HasMaxLength(60)
|
||||
.HasColumnType("nvarchar(60)");
|
||||
|
||||
b.Property<string>("Salt")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("Series")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("TotalChallenge")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("TotalLikes")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("Username")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("DesignationId");
|
||||
|
||||
b.ToTable("Users");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeReadyBackend.Models.UserAchievement", b =>
|
||||
{
|
||||
b.Property<int>("UserId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("AchievementId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("UserId", "AchievementId");
|
||||
|
||||
b.HasIndex("AchievementId");
|
||||
|
||||
b.ToTable("UserAchievements");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeReadyBackend.Models.UserFriend", b =>
|
||||
{
|
||||
b.Property<int>("UserId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("FriendId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<bool>("IsAccepted")
|
||||
.HasColumnType("bit");
|
||||
|
||||
b.HasKey("UserId", "FriendId");
|
||||
|
||||
b.HasIndex("FriendId");
|
||||
|
||||
b.ToTable("UserFriends");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeReadyBackend.Models.UserGroup", b =>
|
||||
{
|
||||
b.Property<int>("UserId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("GroupId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("Grade")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("UserId", "GroupId");
|
||||
|
||||
b.HasIndex("GroupId");
|
||||
|
||||
b.ToTable("UserGroups");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeReadyBackend.Models.UserRandomChallenge", b =>
|
||||
{
|
||||
b.Property<int>("UserId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("RandomChallengeId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("Proof")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("UserId", "RandomChallengeId");
|
||||
|
||||
b.HasIndex("RandomChallengeId");
|
||||
|
||||
b.ToTable("UserRandomChallenges");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeReadyBackend.Models.Message", b =>
|
||||
{
|
||||
b.HasOne("BeReadyBackend.Models.Group", "Group")
|
||||
.WithMany("Messages")
|
||||
.HasForeignKey("GroupId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("BeReadyBackend.Models.User", "User")
|
||||
.WithMany("Messages")
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Group");
|
||||
|
||||
b.Navigation("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeReadyBackend.Models.Post", b =>
|
||||
{
|
||||
b.HasOne("BeReadyBackend.Models.User", "User")
|
||||
.WithMany("Posts")
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeReadyBackend.Models.User", b =>
|
||||
{
|
||||
b.HasOne("BeReadyBackend.Models.Designation", "Designation")
|
||||
.WithMany("Users")
|
||||
.HasForeignKey("DesignationId");
|
||||
|
||||
b.Navigation("Designation");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeReadyBackend.Models.UserAchievement", b =>
|
||||
{
|
||||
b.HasOne("BeReadyBackend.Models.Achievement", "Achievement")
|
||||
.WithMany("UserAchievements")
|
||||
.HasForeignKey("AchievementId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("BeReadyBackend.Models.User", "User")
|
||||
.WithMany("UserAchievements")
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Achievement");
|
||||
|
||||
b.Navigation("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeReadyBackend.Models.UserFriend", b =>
|
||||
{
|
||||
b.HasOne("BeReadyBackend.Models.User", "Friend")
|
||||
.WithMany()
|
||||
.HasForeignKey("FriendId")
|
||||
.OnDelete(DeleteBehavior.Restrict)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("BeReadyBackend.Models.User", "User")
|
||||
.WithMany("UserFriends")
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Restrict)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Friend");
|
||||
|
||||
b.Navigation("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeReadyBackend.Models.UserGroup", b =>
|
||||
{
|
||||
b.HasOne("BeReadyBackend.Models.Group", "Group")
|
||||
.WithMany("UserGroups")
|
||||
.HasForeignKey("GroupId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("BeReadyBackend.Models.User", "User")
|
||||
.WithMany("UserGroups")
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Group");
|
||||
|
||||
b.Navigation("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeReadyBackend.Models.UserRandomChallenge", b =>
|
||||
{
|
||||
b.HasOne("BeReadyBackend.Models.RandomChallenge", "RandomChallenge")
|
||||
.WithMany("UserRandomChallenges")
|
||||
.HasForeignKey("RandomChallengeId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("BeReadyBackend.Models.User", "User")
|
||||
.WithMany("UserRandomChallenges")
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("RandomChallenge");
|
||||
|
||||
b.Navigation("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeReadyBackend.Models.Achievement", b =>
|
||||
{
|
||||
b.Navigation("UserAchievements");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeReadyBackend.Models.Designation", b =>
|
||||
{
|
||||
b.Navigation("Users");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeReadyBackend.Models.Group", b =>
|
||||
{
|
||||
b.Navigation("Messages");
|
||||
|
||||
b.Navigation("UserGroups");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeReadyBackend.Models.RandomChallenge", b =>
|
||||
{
|
||||
b.Navigation("UserRandomChallenges");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeReadyBackend.Models.User", b =>
|
||||
{
|
||||
b.Navigation("Messages");
|
||||
|
||||
b.Navigation("Posts");
|
||||
|
||||
b.Navigation("UserAchievements");
|
||||
|
||||
b.Navigation("UserFriends");
|
||||
|
||||
b.Navigation("UserGroups");
|
||||
|
||||
b.Navigation("UserRandomChallenges");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace BeReadyBackend.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class EditedDatabase : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -71,30 +71,10 @@ namespace BeReadyBackend.Migrations
|
||||
b.Property<DateTime>("CreationDate")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<string>("Description")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("Duration")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<bool>("IsFinished")
|
||||
.HasColumnType("bit");
|
||||
|
||||
b.Property<string>("Label")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<DateTime?>("StartedVote")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<string>("Title")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("VoteDuration")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Groups");
|
||||
@@ -130,7 +110,7 @@ namespace BeReadyBackend.Migrations
|
||||
b.ToTable("Messages");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeReadyBackend.Models.RandomChallenge", b =>
|
||||
modelBuilder.Entity("BeReadyBackend.Models.Post", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
@@ -138,9 +118,33 @@ namespace BeReadyBackend.Migrations
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("Duration")
|
||||
b.Property<DateTime>("CreationDate")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<string>("Libelle")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("Likes")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("UserId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("UserId");
|
||||
|
||||
b.ToTable("Posts");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeReadyBackend.Models.RandomChallenge", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<DateTime?>("GeneratedAt")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
@@ -196,22 +200,13 @@ namespace BeReadyBackend.Migrations
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("Score")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Series")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("TotalBonusChallenge")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("TotalChallenge")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("TotalPodium")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("TotalWin")
|
||||
b.Property<int>("TotalLikes")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("Username")
|
||||
@@ -270,15 +265,6 @@ namespace BeReadyBackend.Migrations
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Proof")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("Score")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int?>("VotedProofId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("UserId", "GroupId");
|
||||
|
||||
b.HasIndex("GroupId");
|
||||
@@ -323,6 +309,17 @@ namespace BeReadyBackend.Migrations
|
||||
b.Navigation("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeReadyBackend.Models.Post", b =>
|
||||
{
|
||||
b.HasOne("BeReadyBackend.Models.User", "User")
|
||||
.WithMany("Posts")
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeReadyBackend.Models.User", b =>
|
||||
{
|
||||
b.HasOne("BeReadyBackend.Models.Designation", "Designation")
|
||||
@@ -434,6 +431,8 @@ namespace BeReadyBackend.Migrations
|
||||
{
|
||||
b.Navigation("Messages");
|
||||
|
||||
b.Navigation("Posts");
|
||||
|
||||
b.Navigation("UserAchievements");
|
||||
|
||||
b.Navigation("UserFriends");
|
||||
|
||||
@@ -6,14 +6,7 @@ public class Group
|
||||
{
|
||||
[Key] public int Id { get; set; }
|
||||
[Required, Length(2, 100)] public string? Label { get; set; }
|
||||
[Required] public bool IsFinished { get; set; }
|
||||
|
||||
[Required, Length(2, 200)] public string? Title { get; set; }
|
||||
[Required, Length(2, 200)] public string? Description { get; set; }
|
||||
[Required] public int Duration { get; set; }
|
||||
[Required] public DateTime CreationDate { get; set; }
|
||||
public DateTime? StartedVote { get; set; }
|
||||
public int VoteDuration { get; set; } = 3;
|
||||
|
||||
public List<Message>? Messages { get; set; }
|
||||
public List<UserGroup>? UserGroups { get; set; }
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace BeReadyBackend.Models;
|
||||
|
||||
public class Post
|
||||
{
|
||||
[Key] public int Id { get; set; }
|
||||
[Length(2, 200)] public string? Libelle { get; set; }
|
||||
[Required] public DateTime CreationDate { get; set; }
|
||||
[Required] public int Likes { get; set; } = 0;
|
||||
|
||||
public User? User { get; set; }
|
||||
public int UserId { get; set; }
|
||||
}
|
||||
@@ -7,7 +7,6 @@ public class RandomChallenge
|
||||
[Key] public int Id { get; set; }
|
||||
[Required, Length(2, 200)] public string? Label { get; set; }
|
||||
[Required, Length(2, 200)] public string? Libelle { get; set; }
|
||||
[Required] public int Duration { get; set; }
|
||||
[Required] public bool IsAlreadyPast { get; set; }
|
||||
|
||||
public DateTime? GeneratedAt { get; set; }
|
||||
|
||||
@@ -9,21 +9,19 @@ public class User
|
||||
[Required, Length(2, 50)] public string? Name { get; set; }
|
||||
[Required, Length(2, 50)] public string? Username { get; set; }
|
||||
[Required, MaxLength(100)] public string? Email { get; set; }
|
||||
[Required] public DateTime CreationDate { get; set; }
|
||||
[Required] public DateTime CreationDate { get; set; } = DateTime.Now;
|
||||
[Required, MaxLength(60)] public string? Password { get; set; }
|
||||
[Required] public string? Salt { get; set; }
|
||||
[Required,] public int Score { get; set; }
|
||||
[Required] public int TotalWin { get; set; }
|
||||
[Required] public int TotalChallenge { get; set; }
|
||||
[Required] public int TotalPodium { get; set; }
|
||||
[Required] public int TotalBonusChallenge { get; set; }
|
||||
[Required] public int Series { get; set; }
|
||||
[Required] public int TotalLikes { get; set; } = 0;
|
||||
[Required] public int TotalChallenge { get; set; } = 0;
|
||||
[Required] public int Series { get; set; } = 0;
|
||||
|
||||
public Designation? Designation { get; set; }
|
||||
public int? DesignationId { get; set; }
|
||||
|
||||
public List<UserFriend>? UserFriends { get; set; }
|
||||
public List<Message>? Messages { get; set; }
|
||||
public List<Post>? Posts { get; set; }
|
||||
public List<UserRandomChallenge>? UserRandomChallenges { get; set; }
|
||||
public List<UserAchievement>? UserAchievements { get; set; }
|
||||
public List<UserGroup>? UserGroups { get; set; }
|
||||
|
||||
@@ -11,10 +11,6 @@ public class UserGroup
|
||||
|
||||
public Group? Group { get; set; }
|
||||
[Required] public int GroupId { get; set; }
|
||||
|
||||
public string? Proof { get; set; }
|
||||
|
||||
|
||||
[Required] public string? Grade { get; set; }
|
||||
public int? VotedProofId { get; set; }
|
||||
[Required] public int Score { get; set; }
|
||||
}
|
||||
@@ -3,6 +3,7 @@ using AutoMapper.EquivalencyExpression;
|
||||
using BeReadyBackend;
|
||||
using BeReadyBackend.Hubs;
|
||||
using BeReadyBackend.MappingProfiles;
|
||||
using BeReadyBackend.Models;
|
||||
using FastEndpoints;
|
||||
using FastEndpoints.Swagger;
|
||||
using FastEndpoints.Security;
|
||||
@@ -43,6 +44,7 @@ builder.Services.AddScoped<UserFriendsRepository>();
|
||||
builder.Services.AddScoped<UserGroupsRepository>();
|
||||
builder.Services.AddScoped<UserRandomChallengesRepository>();
|
||||
builder.Services.AddScoped<UsersRepository>();
|
||||
builder.Services.AddScoped<PostsRepository>();
|
||||
|
||||
builder.Services.AddSignalR();
|
||||
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
using BeReadyBackend.Models;
|
||||
|
||||
namespace BeReadyBackend.Repositories;
|
||||
|
||||
public class PostsRepository(BeReadyDbContext beReadyDbContext, AutoMapper.IMapper mapper) : BeReadyRepository<Post>(beReadyDbContext, mapper);
|
||||
@@ -11,6 +11,6 @@ public class GetFriendsByUserIdSpec : Specification<UserFriend>
|
||||
.Include(x => x.User)
|
||||
.Include(x => x.Friend)
|
||||
.Where(x => x.UserId == userId && x.IsAccepted)
|
||||
.OrderByDescending(x => x.Friend!.Score);
|
||||
.OrderByDescending(x => x.Friend!.TotalLikes);
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
using Ardalis.Specification;
|
||||
using BeReadyBackend.Models;
|
||||
|
||||
namespace BeReadyBackend.Specifications.Groups;
|
||||
|
||||
public class GetGroupRankSpec : Specification<UserGroup>
|
||||
{
|
||||
public GetGroupRankSpec(int id)
|
||||
{
|
||||
Query
|
||||
.Where(x => x.GroupId == id)
|
||||
.OrderByDescending(x => x.Score);
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,7 @@ public class GetUsersByScoreSpec : Specification<User>
|
||||
public GetUsersByScoreSpec()
|
||||
{
|
||||
Query
|
||||
.OrderByDescending(x => x.Score)
|
||||
.OrderByDescending(x => x.TotalLikes)
|
||||
.Take(20);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user