diff --git a/Inflow.Api/Extensions/ConfigureServicesExtensions.cs b/Inflow.Api/Extensions/ConfigureServicesExtensions.cs index d84769f..4b700a7 100644 --- a/Inflow.Api/Extensions/ConfigureServicesExtensions.cs +++ b/Inflow.Api/Extensions/ConfigureServicesExtensions.cs @@ -1,9 +1,9 @@ -using DiyorMarket.Infrastructure.Persistence.Repositories; -using DiyorMarket.Services; +using DiyorMarket.Services; using Inflow.Domain.Intefaces.Services; using Inflow.Domain.Interfaces.Repositories; using Inflow.Domain.Interfaces.Services; using Inflow.Infrastructure; +using Inflow.Infrastructure.Persistence.Repositories; using Microsoft.EntityFrameworkCore; using Serilog; @@ -61,7 +61,7 @@ public static IServiceCollection ConfigureDatabaseContext(this IServiceCollectio var builder = WebApplication.CreateBuilder(); services.AddDbContext(options => - options.UseSqlServer(builder.Configuration.GetConnectionString("DiyorMarketConection"))); + options.UseSqlServer(builder.Configuration.GetConnectionString("InflowConnection"))); return services; } diff --git a/Inflow.Api/Inflow.Api.csproj b/Inflow.Api/Inflow.Api.csproj index 8c6b36a..391ae48 100644 --- a/Inflow.Api/Inflow.Api.csproj +++ b/Inflow.Api/Inflow.Api.csproj @@ -4,7 +4,7 @@ net8.0 enable enable - true + false diff --git a/Inflow.Api/appsettings.json b/Inflow.Api/appsettings.json index 10f68b8..5095512 100644 --- a/Inflow.Api/appsettings.json +++ b/Inflow.Api/appsettings.json @@ -5,5 +5,8 @@ "Microsoft.AspNetCore": "Warning" } }, + "ConnectionStrings": { + "InflowConnection": "Data Source=DESKTOP-B7KIDHK\\SQLEXPRESS02;Initial Catalog=Inflow;Integrated Security=True;Trust Server Certificate=True" + }, "AllowedHosts": "*" } diff --git a/Inflow.Infrastructure/Configurations/CategoryEntityConfiguration.cs b/Inflow.Infrastructure/Persistence/Configurations/CategoryEntityConfiguration.cs similarity index 91% rename from Inflow.Infrastructure/Configurations/CategoryEntityConfiguration.cs rename to Inflow.Infrastructure/Persistence/Configurations/CategoryEntityConfiguration.cs index 1575816..fdaf283 100644 --- a/Inflow.Infrastructure/Configurations/CategoryEntityConfiguration.cs +++ b/Inflow.Infrastructure/Persistence/Configurations/CategoryEntityConfiguration.cs @@ -2,7 +2,7 @@ using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; -namespace Inflow.Infrastructure.Configurations +namespace Inflow.Infrastructure.Persistence.Configurations { internal class CategoryEntityConfiguration : IEntityTypeConfiguration { diff --git a/Inflow.Infrastructure/Configurations/CustomerEntityConfiguration.cs b/Inflow.Infrastructure/Persistence/Configurations/CustomerEntityConfiguration.cs similarity index 93% rename from Inflow.Infrastructure/Configurations/CustomerEntityConfiguration.cs rename to Inflow.Infrastructure/Persistence/Configurations/CustomerEntityConfiguration.cs index 6653b39..2d9aa63 100644 --- a/Inflow.Infrastructure/Configurations/CustomerEntityConfiguration.cs +++ b/Inflow.Infrastructure/Persistence/Configurations/CustomerEntityConfiguration.cs @@ -2,7 +2,7 @@ using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; -namespace Inflow.Infrastructure.Configurations +namespace Inflow.Infrastructure.Persistence.Configurations { internal class CustomerEntityConfiguration : IEntityTypeConfiguration { diff --git a/Inflow.Infrastructure/Configurations/ProductEntityConfiguration.cs b/Inflow.Infrastructure/Persistence/Configurations/ProductEntityConfiguration.cs similarity index 95% rename from Inflow.Infrastructure/Configurations/ProductEntityConfiguration.cs rename to Inflow.Infrastructure/Persistence/Configurations/ProductEntityConfiguration.cs index 6816557..4d9d271 100644 --- a/Inflow.Infrastructure/Configurations/ProductEntityConfiguration.cs +++ b/Inflow.Infrastructure/Persistence/Configurations/ProductEntityConfiguration.cs @@ -2,7 +2,7 @@ using Microsoft.EntityFrameworkCore.Metadata.Builders; using Microsoft.EntityFrameworkCore; -namespace Inflow.Infrastructure.Configurations +namespace Inflow.Infrastructure.Persistence.Configurations { internal class ProductEntityConfiguration : IEntityTypeConfiguration { diff --git a/Inflow.Infrastructure/Configurations/SaleEntityConfiguration.cs b/Inflow.Infrastructure/Persistence/Configurations/SaleEntityConfiguration.cs similarity index 91% rename from Inflow.Infrastructure/Configurations/SaleEntityConfiguration.cs rename to Inflow.Infrastructure/Persistence/Configurations/SaleEntityConfiguration.cs index 7672ad5..00ad956 100644 --- a/Inflow.Infrastructure/Configurations/SaleEntityConfiguration.cs +++ b/Inflow.Infrastructure/Persistence/Configurations/SaleEntityConfiguration.cs @@ -2,7 +2,7 @@ using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; -namespace Inflow.Infrastructure.Configurations +namespace Inflow.Infrastructure.Persistence.Configurations { public class SaleEntityConfiguration : IEntityTypeConfiguration { diff --git a/Inflow.Infrastructure/Configurations/SaleItemEntityConfiguration.cs b/Inflow.Infrastructure/Persistence/Configurations/SaleItemEntityConfiguration.cs similarity index 93% rename from Inflow.Infrastructure/Configurations/SaleItemEntityConfiguration.cs rename to Inflow.Infrastructure/Persistence/Configurations/SaleItemEntityConfiguration.cs index 5ac0bd8..aa196c3 100644 --- a/Inflow.Infrastructure/Configurations/SaleItemEntityConfiguration.cs +++ b/Inflow.Infrastructure/Persistence/Configurations/SaleItemEntityConfiguration.cs @@ -2,7 +2,7 @@ using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; -namespace Inflow.Infrastructure.Configurations +namespace Inflow.Infrastructure.Persistence.Configurations { internal class SaleItemEntityConfiguration : IEntityTypeConfiguration { diff --git a/Inflow.Infrastructure/Configurations/SupplierEntityConfiguration.cs b/Inflow.Infrastructure/Persistence/Configurations/SupplierEntityConfiguration.cs similarity index 94% rename from Inflow.Infrastructure/Configurations/SupplierEntityConfiguration.cs rename to Inflow.Infrastructure/Persistence/Configurations/SupplierEntityConfiguration.cs index e1ea448..cee32e4 100644 --- a/Inflow.Infrastructure/Configurations/SupplierEntityConfiguration.cs +++ b/Inflow.Infrastructure/Persistence/Configurations/SupplierEntityConfiguration.cs @@ -2,7 +2,7 @@ using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; -namespace Inflow.Infrastructure.Configurations +namespace Inflow.Infrastructure.Persistence.Configurations { internal class SupplierEntityConfiguration : IEntityTypeConfiguration { diff --git a/Inflow.Infrastructure/Configurations/SupplyEntityConfiguration.cs b/Inflow.Infrastructure/Persistence/Configurations/SupplyEntityConfiguration.cs similarity index 91% rename from Inflow.Infrastructure/Configurations/SupplyEntityConfiguration.cs rename to Inflow.Infrastructure/Persistence/Configurations/SupplyEntityConfiguration.cs index c8946de..d580e60 100644 --- a/Inflow.Infrastructure/Configurations/SupplyEntityConfiguration.cs +++ b/Inflow.Infrastructure/Persistence/Configurations/SupplyEntityConfiguration.cs @@ -2,7 +2,7 @@ using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; -namespace Inflow.Infrastructure.Configurations +namespace Inflow.Infrastructure.Persistence.Configurations { internal class SupplyEntityConfiguration : IEntityTypeConfiguration { diff --git a/Inflow.Infrastructure/Configurations/SupplyItemEntityConfiguration.cs b/Inflow.Infrastructure/Persistence/Configurations/SupplyItemEntityConfiguration.cs similarity index 93% rename from Inflow.Infrastructure/Configurations/SupplyItemEntityConfiguration.cs rename to Inflow.Infrastructure/Persistence/Configurations/SupplyItemEntityConfiguration.cs index d952a4f..f57a6f0 100644 --- a/Inflow.Infrastructure/Configurations/SupplyItemEntityConfiguration.cs +++ b/Inflow.Infrastructure/Persistence/Configurations/SupplyItemEntityConfiguration.cs @@ -2,7 +2,7 @@ using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; -namespace Inflow.Infrastructure.Configurations +namespace Inflow.Infrastructure.Persistence.Configurations { internal class SupplyItemEntityConfiguration : IEntityTypeConfiguration { diff --git a/Inflow.Infrastructure/Configurations/UserEntityConfiguration.cs b/Inflow.Infrastructure/Persistence/Configurations/UserEntityConfiguration.cs similarity index 93% rename from Inflow.Infrastructure/Configurations/UserEntityConfiguration.cs rename to Inflow.Infrastructure/Persistence/Configurations/UserEntityConfiguration.cs index bd707eb..3a40cdc 100644 --- a/Inflow.Infrastructure/Configurations/UserEntityConfiguration.cs +++ b/Inflow.Infrastructure/Persistence/Configurations/UserEntityConfiguration.cs @@ -1,7 +1,7 @@ using Inflow.Domain.Entities; using Microsoft.EntityFrameworkCore; -namespace Inflow.Infrastructure.Configurations +namespace Inflow.Infrastructure.Persistence.Configurations { internal class UserEntityConfiguration : IEntityTypeConfiguration { diff --git a/Inflow.Infrastructure/Persistence/Migrations/20240402132120_Initial_Create.Designer.cs b/Inflow.Infrastructure/Persistence/Migrations/20240402132120_Initial_Create.Designer.cs new file mode 100644 index 0000000..3ca6e4d --- /dev/null +++ b/Inflow.Infrastructure/Persistence/Migrations/20240402132120_Initial_Create.Designer.cs @@ -0,0 +1,384 @@ +// +using System; +using Inflow.Infrastructure; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace Inflow.Infrastructure.Migrations +{ + [DbContext(typeof(InflowDbContext))] + [Migration("20240402132120_Initial_Create")] + partial class Initial_Create + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.2") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("Inflow.Domain.Entities.Category", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Name") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.HasKey("Id"); + + b.ToTable("Category", (string)null); + }); + + modelBuilder.Entity("Inflow.Domain.Entities.Customer", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("FirstName") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("LastName") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("PhoneNumber") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.HasKey("Id"); + + b.ToTable("Customer", (string)null); + }); + + modelBuilder.Entity("Inflow.Domain.Entities.Product", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CategoryId") + .HasColumnType("int"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("ExpireDate") + .HasColumnType("datetime2"); + + b.Property("LowQuantityAmount") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasDefaultValue(5); + + b.Property("Name") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("Price") + .HasColumnType("money"); + + b.Property("QuantityInStock") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("CategoryId"); + + b.ToTable("Product", (string)null); + }); + + modelBuilder.Entity("Inflow.Domain.Entities.Sale", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CustomerId") + .HasColumnType("int"); + + b.Property("SaleDate") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.HasIndex("CustomerId"); + + b.ToTable("Sale", (string)null); + }); + + modelBuilder.Entity("Inflow.Domain.Entities.SaleItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ProductId") + .HasColumnType("int"); + + b.Property("Quantity") + .HasColumnType("integer"); + + b.Property("SaleId") + .HasColumnType("int"); + + b.Property("UnitPrice") + .HasColumnType("money"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.HasIndex("SaleId"); + + b.ToTable("SaleItem", (string)null); + }); + + modelBuilder.Entity("Inflow.Domain.Entities.Supplier", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Company") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("FirstName") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("LastName") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("PhoneNumber") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.HasKey("Id"); + + b.ToTable("Supplier", (string)null); + }); + + modelBuilder.Entity("Inflow.Domain.Entities.Supply", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("SupplierId") + .HasColumnType("int"); + + b.Property("SupplyDate") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.HasIndex("SupplierId"); + + b.ToTable("Supply", (string)null); + }); + + modelBuilder.Entity("Inflow.Domain.Entities.SupplyItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ProductId") + .HasColumnType("int"); + + b.Property("Quantity") + .HasColumnType("integer"); + + b.Property("SupplyId") + .HasColumnType("int"); + + b.Property("UnitPrice") + .HasColumnType("money"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.HasIndex("SupplyId"); + + b.ToTable("SupplyItem", (string)null); + }); + + modelBuilder.Entity("Inflow.Domain.Entities.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Login") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasAnnotation("MinLength", 8); + + b.Property("Name") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("Password") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasAnnotation("MinLength", 8); + + b.Property("Phone") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.HasKey("Id"); + + b.ToTable("User", (string)null); + }); + + modelBuilder.Entity("Inflow.Domain.Entities.Product", b => + { + b.HasOne("Inflow.Domain.Entities.Category", "Category") + .WithMany("Products") + .HasForeignKey("CategoryId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Category"); + }); + + modelBuilder.Entity("Inflow.Domain.Entities.Sale", b => + { + b.HasOne("Inflow.Domain.Entities.Customer", "Customer") + .WithMany("Sales") + .HasForeignKey("CustomerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Customer"); + }); + + modelBuilder.Entity("Inflow.Domain.Entities.SaleItem", b => + { + b.HasOne("Inflow.Domain.Entities.Product", "Product") + .WithMany("SaleItems") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Inflow.Domain.Entities.Sale", "Sale") + .WithMany("SaleItems") + .HasForeignKey("SaleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Product"); + + b.Navigation("Sale"); + }); + + modelBuilder.Entity("Inflow.Domain.Entities.Supply", b => + { + b.HasOne("Inflow.Domain.Entities.Supplier", "Supplier") + .WithMany("Supplies") + .HasForeignKey("SupplierId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Supplier"); + }); + + modelBuilder.Entity("Inflow.Domain.Entities.SupplyItem", b => + { + b.HasOne("Inflow.Domain.Entities.Product", "Product") + .WithMany("SupplyItems") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Inflow.Domain.Entities.Supply", "Supply") + .WithMany("SupplyItems") + .HasForeignKey("SupplyId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Product"); + + b.Navigation("Supply"); + }); + + modelBuilder.Entity("Inflow.Domain.Entities.Category", b => + { + b.Navigation("Products"); + }); + + modelBuilder.Entity("Inflow.Domain.Entities.Customer", b => + { + b.Navigation("Sales"); + }); + + modelBuilder.Entity("Inflow.Domain.Entities.Product", b => + { + b.Navigation("SaleItems"); + + b.Navigation("SupplyItems"); + }); + + modelBuilder.Entity("Inflow.Domain.Entities.Sale", b => + { + b.Navigation("SaleItems"); + }); + + modelBuilder.Entity("Inflow.Domain.Entities.Supplier", b => + { + b.Navigation("Supplies"); + }); + + modelBuilder.Entity("Inflow.Domain.Entities.Supply", b => + { + b.Navigation("SupplyItems"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Inflow.Infrastructure/Persistence/Migrations/20240402132120_Initial_Create.cs b/Inflow.Infrastructure/Persistence/Migrations/20240402132120_Initial_Create.cs new file mode 100644 index 0000000..95f79b7 --- /dev/null +++ b/Inflow.Infrastructure/Persistence/Migrations/20240402132120_Initial_Create.cs @@ -0,0 +1,262 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Inflow.Infrastructure.Migrations +{ + /// + public partial class Initial_Create : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "Category", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + Name = table.Column(type: "nvarchar(255)", maxLength: 255, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Category", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Customer", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + FirstName = table.Column(type: "nvarchar(255)", maxLength: 255, nullable: false), + LastName = table.Column(type: "nvarchar(255)", maxLength: 255, nullable: true), + PhoneNumber = table.Column(type: "nvarchar(255)", maxLength: 255, nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Customer", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Supplier", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + FirstName = table.Column(type: "nvarchar(255)", maxLength: 255, nullable: false), + LastName = table.Column(type: "nvarchar(255)", maxLength: 255, nullable: true), + PhoneNumber = table.Column(type: "nvarchar(255)", maxLength: 255, nullable: true), + Company = table.Column(type: "nvarchar(255)", maxLength: 255, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Supplier", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "User", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + Name = table.Column(type: "nvarchar(255)", maxLength: 255, nullable: false), + Phone = table.Column(type: "nvarchar(255)", maxLength: 255, nullable: true), + Login = table.Column(type: "nvarchar(255)", maxLength: 255, nullable: false), + Password = table.Column(type: "nvarchar(255)", maxLength: 255, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_User", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Product", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + Name = table.Column(type: "nvarchar(255)", maxLength: 255, nullable: false), + Description = table.Column(type: "nvarchar(500)", maxLength: 500, nullable: false), + Price = table.Column(type: "money", nullable: false), + ExpireDate = table.Column(type: "datetime2", nullable: false), + QuantityInStock = table.Column(type: "int", nullable: false), + LowQuantityAmount = table.Column(type: "int", nullable: false, defaultValue: 5), + CategoryId = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Product", x => x.Id); + table.ForeignKey( + name: "FK_Product_Category_CategoryId", + column: x => x.CategoryId, + principalTable: "Category", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "Sale", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + SaleDate = table.Column(type: "datetime2", nullable: false), + CustomerId = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Sale", x => x.Id); + table.ForeignKey( + name: "FK_Sale_Customer_CustomerId", + column: x => x.CustomerId, + principalTable: "Customer", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "Supply", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + SupplyDate = table.Column(type: "datetime2", nullable: false), + SupplierId = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Supply", x => x.Id); + table.ForeignKey( + name: "FK_Supply_Supplier_SupplierId", + column: x => x.SupplierId, + principalTable: "Supplier", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "SaleItem", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + Quantity = table.Column(type: "integer", nullable: false), + UnitPrice = table.Column(type: "money", nullable: false), + ProductId = table.Column(type: "int", nullable: false), + SaleId = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_SaleItem", x => x.Id); + table.ForeignKey( + name: "FK_SaleItem_Product_ProductId", + column: x => x.ProductId, + principalTable: "Product", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_SaleItem_Sale_SaleId", + column: x => x.SaleId, + principalTable: "Sale", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "SupplyItem", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + Quantity = table.Column(type: "integer", nullable: false), + UnitPrice = table.Column(type: "money", nullable: false), + ProductId = table.Column(type: "int", nullable: false), + SupplyId = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_SupplyItem", x => x.Id); + table.ForeignKey( + name: "FK_SupplyItem_Product_ProductId", + column: x => x.ProductId, + principalTable: "Product", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_SupplyItem_Supply_SupplyId", + column: x => x.SupplyId, + principalTable: "Supply", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateIndex( + name: "IX_Product_CategoryId", + table: "Product", + column: "CategoryId"); + + migrationBuilder.CreateIndex( + name: "IX_Sale_CustomerId", + table: "Sale", + column: "CustomerId"); + + migrationBuilder.CreateIndex( + name: "IX_SaleItem_ProductId", + table: "SaleItem", + column: "ProductId"); + + migrationBuilder.CreateIndex( + name: "IX_SaleItem_SaleId", + table: "SaleItem", + column: "SaleId"); + + migrationBuilder.CreateIndex( + name: "IX_Supply_SupplierId", + table: "Supply", + column: "SupplierId"); + + migrationBuilder.CreateIndex( + name: "IX_SupplyItem_ProductId", + table: "SupplyItem", + column: "ProductId"); + + migrationBuilder.CreateIndex( + name: "IX_SupplyItem_SupplyId", + table: "SupplyItem", + column: "SupplyId"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "SaleItem"); + + migrationBuilder.DropTable( + name: "SupplyItem"); + + migrationBuilder.DropTable( + name: "User"); + + migrationBuilder.DropTable( + name: "Sale"); + + migrationBuilder.DropTable( + name: "Product"); + + migrationBuilder.DropTable( + name: "Supply"); + + migrationBuilder.DropTable( + name: "Customer"); + + migrationBuilder.DropTable( + name: "Category"); + + migrationBuilder.DropTable( + name: "Supplier"); + } + } +} diff --git a/Inflow.Infrastructure/Persistence/Migrations/InflowDbContextModelSnapshot.cs b/Inflow.Infrastructure/Persistence/Migrations/InflowDbContextModelSnapshot.cs new file mode 100644 index 0000000..388271f --- /dev/null +++ b/Inflow.Infrastructure/Persistence/Migrations/InflowDbContextModelSnapshot.cs @@ -0,0 +1,381 @@ +// +using System; +using Inflow.Infrastructure; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace Inflow.Infrastructure.Migrations +{ + [DbContext(typeof(InflowDbContext))] + partial class InflowDbContextModelSnapshot : ModelSnapshot + { + protected override void BuildModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.2") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("Inflow.Domain.Entities.Category", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Name") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.HasKey("Id"); + + b.ToTable("Category", (string)null); + }); + + modelBuilder.Entity("Inflow.Domain.Entities.Customer", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("FirstName") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("LastName") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("PhoneNumber") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.HasKey("Id"); + + b.ToTable("Customer", (string)null); + }); + + modelBuilder.Entity("Inflow.Domain.Entities.Product", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CategoryId") + .HasColumnType("int"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("ExpireDate") + .HasColumnType("datetime2"); + + b.Property("LowQuantityAmount") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasDefaultValue(5); + + b.Property("Name") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("Price") + .HasColumnType("money"); + + b.Property("QuantityInStock") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("CategoryId"); + + b.ToTable("Product", (string)null); + }); + + modelBuilder.Entity("Inflow.Domain.Entities.Sale", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CustomerId") + .HasColumnType("int"); + + b.Property("SaleDate") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.HasIndex("CustomerId"); + + b.ToTable("Sale", (string)null); + }); + + modelBuilder.Entity("Inflow.Domain.Entities.SaleItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ProductId") + .HasColumnType("int"); + + b.Property("Quantity") + .HasColumnType("integer"); + + b.Property("SaleId") + .HasColumnType("int"); + + b.Property("UnitPrice") + .HasColumnType("money"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.HasIndex("SaleId"); + + b.ToTable("SaleItem", (string)null); + }); + + modelBuilder.Entity("Inflow.Domain.Entities.Supplier", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Company") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("FirstName") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("LastName") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("PhoneNumber") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.HasKey("Id"); + + b.ToTable("Supplier", (string)null); + }); + + modelBuilder.Entity("Inflow.Domain.Entities.Supply", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("SupplierId") + .HasColumnType("int"); + + b.Property("SupplyDate") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.HasIndex("SupplierId"); + + b.ToTable("Supply", (string)null); + }); + + modelBuilder.Entity("Inflow.Domain.Entities.SupplyItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ProductId") + .HasColumnType("int"); + + b.Property("Quantity") + .HasColumnType("integer"); + + b.Property("SupplyId") + .HasColumnType("int"); + + b.Property("UnitPrice") + .HasColumnType("money"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.HasIndex("SupplyId"); + + b.ToTable("SupplyItem", (string)null); + }); + + modelBuilder.Entity("Inflow.Domain.Entities.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Login") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasAnnotation("MinLength", 8); + + b.Property("Name") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("Password") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasAnnotation("MinLength", 8); + + b.Property("Phone") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.HasKey("Id"); + + b.ToTable("User", (string)null); + }); + + modelBuilder.Entity("Inflow.Domain.Entities.Product", b => + { + b.HasOne("Inflow.Domain.Entities.Category", "Category") + .WithMany("Products") + .HasForeignKey("CategoryId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Category"); + }); + + modelBuilder.Entity("Inflow.Domain.Entities.Sale", b => + { + b.HasOne("Inflow.Domain.Entities.Customer", "Customer") + .WithMany("Sales") + .HasForeignKey("CustomerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Customer"); + }); + + modelBuilder.Entity("Inflow.Domain.Entities.SaleItem", b => + { + b.HasOne("Inflow.Domain.Entities.Product", "Product") + .WithMany("SaleItems") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Inflow.Domain.Entities.Sale", "Sale") + .WithMany("SaleItems") + .HasForeignKey("SaleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Product"); + + b.Navigation("Sale"); + }); + + modelBuilder.Entity("Inflow.Domain.Entities.Supply", b => + { + b.HasOne("Inflow.Domain.Entities.Supplier", "Supplier") + .WithMany("Supplies") + .HasForeignKey("SupplierId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Supplier"); + }); + + modelBuilder.Entity("Inflow.Domain.Entities.SupplyItem", b => + { + b.HasOne("Inflow.Domain.Entities.Product", "Product") + .WithMany("SupplyItems") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Inflow.Domain.Entities.Supply", "Supply") + .WithMany("SupplyItems") + .HasForeignKey("SupplyId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Product"); + + b.Navigation("Supply"); + }); + + modelBuilder.Entity("Inflow.Domain.Entities.Category", b => + { + b.Navigation("Products"); + }); + + modelBuilder.Entity("Inflow.Domain.Entities.Customer", b => + { + b.Navigation("Sales"); + }); + + modelBuilder.Entity("Inflow.Domain.Entities.Product", b => + { + b.Navigation("SaleItems"); + + b.Navigation("SupplyItems"); + }); + + modelBuilder.Entity("Inflow.Domain.Entities.Sale", b => + { + b.Navigation("SaleItems"); + }); + + modelBuilder.Entity("Inflow.Domain.Entities.Supplier", b => + { + b.Navigation("Supplies"); + }); + + modelBuilder.Entity("Inflow.Domain.Entities.Supply", b => + { + b.Navigation("SupplyItems"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Inflow.Infrastructure/Repositories/CategoryRepository.cs b/Inflow.Infrastructure/Persistence/Repositories/CategoryRepository.cs similarity index 83% rename from Inflow.Infrastructure/Repositories/CategoryRepository.cs rename to Inflow.Infrastructure/Persistence/Repositories/CategoryRepository.cs index f7bea9f..f2d58d3 100644 --- a/Inflow.Infrastructure/Repositories/CategoryRepository.cs +++ b/Inflow.Infrastructure/Persistence/Repositories/CategoryRepository.cs @@ -2,7 +2,7 @@ using Inflow.Domain.Interfaces.Repositories; using Inflow.Infrastructure; -namespace DiyorMarket.Infrastructure.Persistence.Repositories +namespace Inflow.Infrastructure.Persistence.Repositories { public class CategoryRepository : RepositoryBase, ICategoryRepository { diff --git a/Inflow.Infrastructure/Repositories/CommonRepository.cs b/Inflow.Infrastructure/Persistence/Repositories/CommonRepository.cs similarity index 96% rename from Inflow.Infrastructure/Repositories/CommonRepository.cs rename to Inflow.Infrastructure/Persistence/Repositories/CommonRepository.cs index f8ff4b1..8073e4c 100644 --- a/Inflow.Infrastructure/Repositories/CommonRepository.cs +++ b/Inflow.Infrastructure/Persistence/Repositories/CommonRepository.cs @@ -1,7 +1,6 @@ using Inflow.Domain.Interfaces.Repositories; -using Inflow.Infrastructure; -namespace DiyorMarket.Infrastructure.Persistence.Repositories +namespace Inflow.Infrastructure.Persistence.Repositories { public class CommonRepository : ICommonRepository { diff --git a/Inflow.Infrastructure/Repositories/CustomerRepository.cs b/Inflow.Infrastructure/Persistence/Repositories/CustomerRepository.cs similarity index 75% rename from Inflow.Infrastructure/Repositories/CustomerRepository.cs rename to Inflow.Infrastructure/Persistence/Repositories/CustomerRepository.cs index 31d1c71..e39426b 100644 --- a/Inflow.Infrastructure/Repositories/CustomerRepository.cs +++ b/Inflow.Infrastructure/Persistence/Repositories/CustomerRepository.cs @@ -1,8 +1,7 @@ using Inflow.Domain.Entities; using Inflow.Domain.Interfaces.Repositories; -using Inflow.Infrastructure; -namespace DiyorMarket.Infrastructure.Persistence.Repositories +namespace Inflow.Infrastructure.Persistence.Repositories { public class CustomerRepository : RepositoryBase, ICustomerRepository { diff --git a/Inflow.Infrastructure/Repositories/ProductRepository.cs b/Inflow.Infrastructure/Persistence/Repositories/ProductRepository.cs similarity index 83% rename from Inflow.Infrastructure/Repositories/ProductRepository.cs rename to Inflow.Infrastructure/Persistence/Repositories/ProductRepository.cs index 7a3522e..2f1a6d3 100644 --- a/Inflow.Infrastructure/Repositories/ProductRepository.cs +++ b/Inflow.Infrastructure/Persistence/Repositories/ProductRepository.cs @@ -2,7 +2,7 @@ using Inflow.Domain.Interfaces.Repositories; using Inflow.Infrastructure; -namespace DiyorMarket.Infrastructure.Persistence.Repositories +namespace Inflow.Infrastructure.Persistence.Repositories { public class ProductRepository : RepositoryBase, IProductRepository { diff --git a/Inflow.Infrastructure/Repositories/RepositoryBase.cs b/Inflow.Infrastructure/Persistence/Repositories/RepositoryBase.cs similarity index 93% rename from Inflow.Infrastructure/Repositories/RepositoryBase.cs rename to Inflow.Infrastructure/Persistence/Repositories/RepositoryBase.cs index 2f43fc6..94f2285 100644 --- a/Inflow.Infrastructure/Repositories/RepositoryBase.cs +++ b/Inflow.Infrastructure/Persistence/Repositories/RepositoryBase.cs @@ -1,10 +1,9 @@ using Inflow.Domain.Entities; using Inflow.Domain.Exeptions; using Inflow.Domain.Interfaces.Repositories; -using Inflow.Infrastructure; using Microsoft.EntityFrameworkCore; -namespace DiyorMarket.Infrastructure.Persistence.Repositories +namespace Inflow.Infrastructure.Persistence.Repositories { public class RepositoryBase : IRepositoryBase where T : EntityBase { diff --git a/Inflow.Infrastructure/Repositories/SaleItemRepository.cs b/Inflow.Infrastructure/Persistence/Repositories/SaleItemRepository.cs similarity index 83% rename from Inflow.Infrastructure/Repositories/SaleItemRepository.cs rename to Inflow.Infrastructure/Persistence/Repositories/SaleItemRepository.cs index 0ab1d5f..096d858 100644 --- a/Inflow.Infrastructure/Repositories/SaleItemRepository.cs +++ b/Inflow.Infrastructure/Persistence/Repositories/SaleItemRepository.cs @@ -2,7 +2,7 @@ using Inflow.Domain.Interfaces.Repositories; using Inflow.Infrastructure; -namespace DiyorMarket.Infrastructure.Persistence.Repositories +namespace Inflow.Infrastructure.Persistence.Repositories { public class SaleItemRepository : RepositoryBase, ISaleItemRepository { diff --git a/Inflow.Infrastructure/Repositories/SaleRepository.cs b/Inflow.Infrastructure/Persistence/Repositories/SaleRepository.cs similarity index 82% rename from Inflow.Infrastructure/Repositories/SaleRepository.cs rename to Inflow.Infrastructure/Persistence/Repositories/SaleRepository.cs index df07ff4..60fec01 100644 --- a/Inflow.Infrastructure/Repositories/SaleRepository.cs +++ b/Inflow.Infrastructure/Persistence/Repositories/SaleRepository.cs @@ -2,7 +2,7 @@ using Inflow.Domain.Interfaces.Repositories; using Inflow.Infrastructure; -namespace DiyorMarket.Infrastructure.Persistence.Repositories +namespace Inflow.Infrastructure.Persistence.Repositories { public class SaleRepository : RepositoryBase, ISaleRepository { diff --git a/Inflow.Infrastructure/Repositories/SupplierRepository.cs b/Inflow.Infrastructure/Persistence/Repositories/SupplierRepository.cs similarity index 83% rename from Inflow.Infrastructure/Repositories/SupplierRepository.cs rename to Inflow.Infrastructure/Persistence/Repositories/SupplierRepository.cs index 7365583..c0b171d 100644 --- a/Inflow.Infrastructure/Repositories/SupplierRepository.cs +++ b/Inflow.Infrastructure/Persistence/Repositories/SupplierRepository.cs @@ -2,7 +2,7 @@ using Inflow.Domain.Interfaces.Repositories; using Inflow.Infrastructure; -namespace DiyorMarket.Infrastructure.Persistence.Repositories +namespace Inflow.Infrastructure.Persistence.Repositories { public class SupplierRepository : RepositoryBase, ISupplierRepository { diff --git a/Inflow.Infrastructure/Repositories/SupplyItemRepository.cs b/Inflow.Infrastructure/Persistence/Repositories/SupplyItemRepository.cs similarity index 83% rename from Inflow.Infrastructure/Repositories/SupplyItemRepository.cs rename to Inflow.Infrastructure/Persistence/Repositories/SupplyItemRepository.cs index cd71c5e..41e0ed3 100644 --- a/Inflow.Infrastructure/Repositories/SupplyItemRepository.cs +++ b/Inflow.Infrastructure/Persistence/Repositories/SupplyItemRepository.cs @@ -2,7 +2,7 @@ using Inflow.Domain.Interfaces.Repositories; using Inflow.Infrastructure; -namespace DiyorMarket.Infrastructure.Persistence.Repositories +namespace Inflow.Infrastructure.Persistence.Repositories { public class SupplyItemRepository : RepositoryBase, ISupplyItemRepository { diff --git a/Inflow.Infrastructure/Repositories/SupplyRepository.cs b/Inflow.Infrastructure/Persistence/Repositories/SupplyRepository.cs similarity index 83% rename from Inflow.Infrastructure/Repositories/SupplyRepository.cs rename to Inflow.Infrastructure/Persistence/Repositories/SupplyRepository.cs index 88c6c9d..d7d046b 100644 --- a/Inflow.Infrastructure/Repositories/SupplyRepository.cs +++ b/Inflow.Infrastructure/Persistence/Repositories/SupplyRepository.cs @@ -2,7 +2,7 @@ using Inflow.Domain.Interfaces.Repositories; using Inflow.Infrastructure; -namespace DiyorMarket.Infrastructure.Persistence.Repositories +namespace Inflow.Infrastructure.Persistence.Repositories { public class SupplyRepository : RepositoryBase, ISupplyRepository {