diff --git a/.idea/.idea.ApiEfCoreLibrary/.idea/.gitignore b/.idea/.idea.ApiEfCoreLibrary/.idea/.gitignore new file mode 100644 index 0000000..243b3ea --- /dev/null +++ b/.idea/.idea.ApiEfCoreLibrary/.idea/.gitignore @@ -0,0 +1,13 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Rider ignored files +/projectSettingsUpdater.xml +/contentModel.xml +/.idea.ApiEfCoreLibrary.iml +/modules.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/.idea.ApiEfCoreLibrary/.idea/dataSources.xml b/.idea/.idea.ApiEfCoreLibrary/.idea/dataSources.xml new file mode 100644 index 0000000..7c01f52 --- /dev/null +++ b/.idea/.idea.ApiEfCoreLibrary/.idea/dataSources.xml @@ -0,0 +1,12 @@ + + + + + sqlserver.jb + true + com.jetbrains.jdbc.sqlserver.SqlServerDriver + Server=romaric-thibault.fr,1433 + $ProjectFileDir$ + + + \ No newline at end of file diff --git a/.idea/.idea.ApiEfCoreLibrary/.idea/indexLayout.xml b/.idea/.idea.ApiEfCoreLibrary/.idea/indexLayout.xml new file mode 100644 index 0000000..7b08163 --- /dev/null +++ b/.idea/.idea.ApiEfCoreLibrary/.idea/indexLayout.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/.idea.ApiEfCoreLibrary/.idea/vcs.xml b/.idea/.idea.ApiEfCoreLibrary/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/.idea.ApiEfCoreLibrary/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/ApiEfCoreLibrary/Migrations/20251013105030_FixingDatabase.Designer.cs b/ApiEfCoreLibrary/Migrations/20251013105030_FixingDatabase.Designer.cs new file mode 100644 index 0000000..b583975 --- /dev/null +++ b/ApiEfCoreLibrary/Migrations/20251013105030_FixingDatabase.Designer.cs @@ -0,0 +1,220 @@ +// +using System; +using ApiEfCoreLibrary; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace ApiEfCoreLibrary.Migrations +{ + [DbContext(typeof(LibraryDbContext))] + [Migration("20251013105030_FixingDatabase")] + partial class FixingDatabase + { + /// + 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("ApiEfCoreLibrary.Models.Author", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("FirstName") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.HasKey("Id"); + + b.ToTable("Authors"); + }); + + modelBuilder.Entity("ApiEfCoreLibrary.Models.Book", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("AuthorId") + .HasColumnType("int"); + + b.Property("Isbn") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("ReleaseYear") + .HasColumnType("int"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.HasKey("Id"); + + b.HasIndex("AuthorId"); + + b.ToTable("Books"); + }); + + modelBuilder.Entity("ApiEfCoreLibrary.Models.Loan", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("BookId") + .HasColumnType("int"); + + b.Property("Date") + .HasColumnType("date"); + + b.Property("EffectiveReturningDate") + .HasColumnType("date"); + + b.Property("PlannedReturningDate") + .HasColumnType("date"); + + b.Property("UserId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("BookId"); + + b.HasIndex("UserId"); + + b.ToTable("Loans"); + }); + + modelBuilder.Entity("ApiEfCoreLibrary.Models.Login", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("FullName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("Password") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("Salt") + .IsRequired() + .HasMaxLength(24) + .HasColumnType("nvarchar(24)"); + + b.Property("Username") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.HasKey("Id"); + + b.ToTable("Logins"); + }); + + modelBuilder.Entity("ApiEfCoreLibrary.Models.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("BirthDate") + .HasColumnType("date"); + + b.Property("Email") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("FirstName") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.HasKey("Id"); + + b.ToTable("Users"); + }); + + modelBuilder.Entity("ApiEfCoreLibrary.Models.Book", b => + { + b.HasOne("ApiEfCoreLibrary.Models.Author", "Author") + .WithMany("Books") + .HasForeignKey("AuthorId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Author"); + }); + + modelBuilder.Entity("ApiEfCoreLibrary.Models.Loan", b => + { + b.HasOne("ApiEfCoreLibrary.Models.Book", "Book") + .WithMany() + .HasForeignKey("BookId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("ApiEfCoreLibrary.Models.User", "User") + .WithMany("Loans") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Book"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("ApiEfCoreLibrary.Models.Author", b => + { + b.Navigation("Books"); + }); + + modelBuilder.Entity("ApiEfCoreLibrary.Models.User", b => + { + b.Navigation("Loans"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/ApiEfCoreLibrary/Migrations/20251013105030_FixingDatabase.cs b/ApiEfCoreLibrary/Migrations/20251013105030_FixingDatabase.cs new file mode 100644 index 0000000..f7e92e0 --- /dev/null +++ b/ApiEfCoreLibrary/Migrations/20251013105030_FixingDatabase.cs @@ -0,0 +1,37 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace ApiEfCoreLibrary.Migrations +{ + /// + public partial class FixingDatabase : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "Logins", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + Username = table.Column(type: "nvarchar(100)", maxLength: 100, nullable: false), + FullName = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: false), + Password = table.Column(type: "nvarchar(255)", maxLength: 255, nullable: false), + Salt = table.Column(type: "nvarchar(24)", maxLength: 24, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Logins", x => x.Id); + }); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "Logins"); + } + } +}