Fixed errors on model for group entity and updated endpoint to see all proofs
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
using BeReadyBackend.Repositories;
|
||||
using BeReadyBackend.Specifications.Groups;
|
||||
using FastEndpoints;
|
||||
using Group = BeReadyBackend.Models.Group;
|
||||
|
||||
namespace BeReadyBackend.Endpoints.Groups;
|
||||
|
||||
@@ -10,7 +11,7 @@ public class GroupProofRequest
|
||||
public int Id { get; set; }
|
||||
}
|
||||
|
||||
public class GetAllProofsEndpoint(UserGroupsRepository userGroupsRepository) : Endpoint<GroupProofRequest, List<GetProofDto>>
|
||||
public class GetAllProofsEndpoint(UserGroupsRepository userGroupsRepository, GroupsRepository groupsRepository) : Endpoint<GroupProofRequest, List<GetProofDto>>
|
||||
{
|
||||
public override void Configure()
|
||||
{
|
||||
@@ -19,6 +20,19 @@ public class GetAllProofsEndpoint(UserGroupsRepository userGroupsRepository) : E
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,448 @@
|
||||
// <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("20260323143122_FixedErrorInGroup")]
|
||||
partial class FixedErrorInGroup
|
||||
{
|
||||
/// <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>("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");
|
||||
});
|
||||
|
||||
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.RandomChallenge", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("Duration")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime?>("GeneratedAt")
|
||||
.IsRequired()
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<bool>("IsAlreadyPast")
|
||||
.HasColumnType("bit");
|
||||
|
||||
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>("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")
|
||||
.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.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");
|
||||
|
||||
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.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("UserAchievements");
|
||||
|
||||
b.Navigation("UserFriends");
|
||||
|
||||
b.Navigation("UserGroups");
|
||||
|
||||
b.Navigation("UserRandomChallenges");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace BeReadyBackend.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class FixedErrorInGroup : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AlterColumn<int>(
|
||||
name: "VoteDuration",
|
||||
table: "Groups",
|
||||
type: "int",
|
||||
nullable: false,
|
||||
defaultValue: 0,
|
||||
oldClrType: typeof(int),
|
||||
oldType: "int",
|
||||
oldNullable: true);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AlterColumn<int>(
|
||||
name: "VoteDuration",
|
||||
table: "Groups",
|
||||
type: "int",
|
||||
nullable: true,
|
||||
oldClrType: typeof(int),
|
||||
oldType: "int");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -92,7 +92,7 @@ namespace BeReadyBackend.Migrations
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int?>("VoteDuration")
|
||||
b.Property<int>("VoteDuration")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
@@ -13,7 +13,7 @@ public class Group
|
||||
[Required] public int Duration { get; set; }
|
||||
[Required] public DateTime CreationDate { get; set; }
|
||||
public DateTime? StartedVote { get; set; }
|
||||
public int? VoteDuration { get; set; } = 3;
|
||||
public int VoteDuration { get; set; } = 3;
|
||||
|
||||
public List<Message>? Messages { get; set; }
|
||||
public List<UserGroup>? UserGroups { get; set; }
|
||||
|
||||
Reference in New Issue
Block a user