diff --git a/.idea/.idea.ApiEfCoreLibrary/.idea/.name b/.idea/.idea.ApiEfCoreLibrary/.idea/.name new file mode 100644 index 0000000..0164851 --- /dev/null +++ b/.idea/.idea.ApiEfCoreLibrary/.idea/.name @@ -0,0 +1 @@ +ApiEfCoreLibrary \ No newline at end of file diff --git a/.idea/config/applicationhost.config b/.idea/config/applicationhost.config new file mode 100644 index 0000000..6771b83 --- /dev/null +++ b/.idea/config/applicationhost.config @@ -0,0 +1,983 @@ + + + + + + +
+
+
+
+
+
+
+
+ + +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ +
+
+ +
+
+
+
+
+
+ +
+
+
+
+
+ +
+
+
+ +
+
+ +
+
+ +
+
+
+ + +
+
+
+
+
+
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ApiEfCoreLibrary/Endpoints/Login/UserLoginEndpoint.cs b/ApiEfCoreLibrary/Endpoints/Login/UserLoginEndpoint.cs index 036adb3..a855ea3 100644 --- a/ApiEfCoreLibrary/Endpoints/Login/UserLoginEndpoint.cs +++ b/ApiEfCoreLibrary/Endpoints/Login/UserLoginEndpoint.cs @@ -27,11 +27,11 @@ public class UserLoginEndpoint(LibraryDbContext database) : Endpoint diff --git a/ApiEfCoreLibrary/Migrations/20251013181549_EditingEntityLoginInDatabase.Designer.cs b/ApiEfCoreLibrary/Migrations/20251013181549_EditingEntityLoginInDatabase.Designer.cs new file mode 100644 index 0000000..7bbf419 --- /dev/null +++ b/ApiEfCoreLibrary/Migrations/20251013181549_EditingEntityLoginInDatabase.Designer.cs @@ -0,0 +1,218 @@ +// +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("20251013181549_EditingEntityLoginInDatabase")] + partial class EditingEntityLoginInDatabase + { + /// + 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() + .HasColumnType("nvarchar(max)"); + + b.Property("Salt") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + 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/20251013181549_EditingEntityLoginInDatabase.cs b/ApiEfCoreLibrary/Migrations/20251013181549_EditingEntityLoginInDatabase.cs new file mode 100644 index 0000000..333c65e --- /dev/null +++ b/ApiEfCoreLibrary/Migrations/20251013181549_EditingEntityLoginInDatabase.cs @@ -0,0 +1,54 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace ApiEfCoreLibrary.Migrations +{ + /// + public partial class EditingEntityLoginInDatabase : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "Salt", + table: "Logins", + type: "nvarchar(max)", + nullable: false, + oldClrType: typeof(string), + oldType: "nvarchar(24)", + oldMaxLength: 24); + + migrationBuilder.AlterColumn( + name: "Password", + table: "Logins", + type: "nvarchar(max)", + nullable: false, + oldClrType: typeof(string), + oldType: "nvarchar(255)", + oldMaxLength: 255); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "Salt", + table: "Logins", + type: "nvarchar(24)", + maxLength: 24, + nullable: false, + oldClrType: typeof(string), + oldType: "nvarchar(max)"); + + migrationBuilder.AlterColumn( + name: "Password", + table: "Logins", + type: "nvarchar(255)", + maxLength: 255, + nullable: false, + oldClrType: typeof(string), + oldType: "nvarchar(max)"); + } + } +} diff --git a/ApiEfCoreLibrary/Migrations/LibraryDbContextModelSnapshot.cs b/ApiEfCoreLibrary/Migrations/LibraryDbContextModelSnapshot.cs index a919bb2..2b11797 100644 --- a/ApiEfCoreLibrary/Migrations/LibraryDbContextModelSnapshot.cs +++ b/ApiEfCoreLibrary/Migrations/LibraryDbContextModelSnapshot.cs @@ -123,13 +123,11 @@ namespace ApiEfCoreLibrary.Migrations b.Property("Password") .IsRequired() - .HasMaxLength(255) - .HasColumnType("nvarchar(255)"); + .HasColumnType("nvarchar(max)"); b.Property("Salt") .IsRequired() - .HasMaxLength(24) - .HasColumnType("nvarchar(24)"); + .HasColumnType("nvarchar(max)"); b.Property("Username") .IsRequired()