diff --git a/ElectronicsShop/ElectronicsShopBusinessLogic/BusinessLogic/ClientLogic.cs b/ElectronicsShop/ElectronicsShopBusinessLogic/BusinessLogic/ClientLogic.cs index e594268..9bb23a6 100644 --- a/ElectronicsShop/ElectronicsShopBusinessLogic/BusinessLogic/ClientLogic.cs +++ b/ElectronicsShop/ElectronicsShopBusinessLogic/BusinessLogic/ClientLogic.cs @@ -111,7 +111,8 @@ namespace ElectronicsShopBusinessLogic.BusinessLogic var element = _storage.GetElement(new ClientSearchModel { - Email = model.Email + Email = model.Email, + Passwrod = model.Password, }); if (element != null && element.ID != model.ID) { diff --git a/ElectronicsShop/ElectronicsShopBusinessLogic/BusinessLogic/EmployeeLogic.cs b/ElectronicsShop/ElectronicsShopBusinessLogic/BusinessLogic/EmployeeLogic.cs index 79d7840..aaeb2e4 100644 --- a/ElectronicsShop/ElectronicsShopBusinessLogic/BusinessLogic/EmployeeLogic.cs +++ b/ElectronicsShop/ElectronicsShopBusinessLogic/BusinessLogic/EmployeeLogic.cs @@ -43,7 +43,7 @@ namespace ElectronicsShopBusinessLogic.BusinessLogic { if (model == null) { throw new ArgumentNullException(nameof(model)); } - _logger.LogInformation($"ReadElement.Email:{model.Login}.ID:{model.ID}"); + _logger.LogInformation($"ReadElement.Email:{model.Email}.ID:{model.ID}"); var element = _storage.GetElement(model); if (element == null) { _logger.LogWarning("ReadElement. element not fount"); @@ -91,7 +91,7 @@ namespace ElectronicsShopBusinessLogic.BusinessLogic { _logger.LogInformation($"Client. ID:{model.ID}.ClientFIO:{model.EmployeeFIO}.Password:{model.Password}.Email:{model.Email}."); var element = _storage.GetElement(new EmployeeSearchModel { - Login = model.Email + Email = model.Email }); if (element != null && element.ID != model.ID) { throw new InvalidOperationException("Сотрудник с таким логином уже есть"); diff --git a/ElectronicsShop/ElectronicsShopBusinessLogic/OfficePackage/AbstractSaveToExcelClient.cs b/ElectronicsShop/ElectronicsShopBusinessLogic/OfficePackage/AbstractSaveToExcelClient.cs index 17c65c4..87fd802 100644 --- a/ElectronicsShop/ElectronicsShopBusinessLogic/OfficePackage/AbstractSaveToExcelClient.cs +++ b/ElectronicsShop/ElectronicsShopBusinessLogic/OfficePackage/AbstractSaveToExcelClient.cs @@ -31,7 +31,7 @@ namespace ElectronicsShopBusinessLogic.OfficePackage MergeCells(new ExcelMergeParameters { CellFromName = "A2", - CellToName = "H2" + CellToName = "F2" }); uint rowIndex = 3; diff --git a/ElectronicsShop/ElectronicsShopBusinessLogic/OfficePackage/AbstractSaveToExcelEmployee.cs b/ElectronicsShop/ElectronicsShopBusinessLogic/OfficePackage/AbstractSaveToExcelEmployee.cs index 4e104d3..ce3dc86 100644 --- a/ElectronicsShop/ElectronicsShopBusinessLogic/OfficePackage/AbstractSaveToExcelEmployee.cs +++ b/ElectronicsShop/ElectronicsShopBusinessLogic/OfficePackage/AbstractSaveToExcelEmployee.cs @@ -32,7 +32,7 @@ namespace ElectronicsShopBusinessLogic.OfficePackage MergeCells(new ExcelMergeParameters { CellFromName = "A2", - CellToName = "H2" + CellToName = "K2" }); uint rowIndex = 3; diff --git a/ElectronicsShop/ElectronicsShopBusinessLogic/OfficePackage/AbstractSaveToWordClient.cs b/ElectronicsShop/ElectronicsShopBusinessLogic/OfficePackage/AbstractSaveToWordClient.cs index f111e34..c861fce 100644 --- a/ElectronicsShop/ElectronicsShopBusinessLogic/OfficePackage/AbstractSaveToWordClient.cs +++ b/ElectronicsShop/ElectronicsShopBusinessLogic/OfficePackage/AbstractSaveToWordClient.cs @@ -54,16 +54,6 @@ namespace ElectronicsShopBusinessLogic.OfficePackage } }); - CreateParagraph(new WordParagraph - { - Texts = new List<(string, WordTextProperties)> { ("Номер товара Товар Цена Количество Статья затрат", new WordTextProperties { Bold = false, Size = "24", }) }, - TextProperties = new WordTextProperties - { - Size = "24", - JustificationType = WordJustificationType.Both - } - }); - double sum = 0; foreach (var products in info.Products) { @@ -72,9 +62,9 @@ namespace ElectronicsShopBusinessLogic.OfficePackage sum += products.Price * products.count; CreateParagraph(new WordParagraph { - Texts = new List<(string, WordTextProperties)> { ($"{products.ID.ToString()} {products.ProductName.ToString()} " + - $"{ (products.Price * products.count).ToString()} {products.count.ToString()} " + - $"{products.CostItemName.ToString()}", new WordTextProperties { Bold = false, Size = "24", }) }, + Texts = new List<(string, WordTextProperties)> { ($"ID товара:{products.ID.ToString()}/Название:{products.ProductName.ToString()}/" + + $"Стоимость:{(products.Price * products.count).ToString()}/Количество:{products.count.ToString()}/" + + $"Статья_затрат:{products.CostItemName.ToString()}", new WordTextProperties { Bold = false, Size = "24", }) }, TextProperties = new WordTextProperties { Size = "24", diff --git a/ElectronicsShop/ElectronicsShopBusinessLogic/OfficePackage/AbstractSaveToWordEmployee.cs b/ElectronicsShop/ElectronicsShopBusinessLogic/OfficePackage/AbstractSaveToWordEmployee.cs index 0718557..3e87bb0 100644 --- a/ElectronicsShop/ElectronicsShopBusinessLogic/OfficePackage/AbstractSaveToWordEmployee.cs +++ b/ElectronicsShop/ElectronicsShopBusinessLogic/OfficePackage/AbstractSaveToWordEmployee.cs @@ -38,13 +38,13 @@ namespace ElectronicsShopBusinessLogic.OfficePackage Texts = new List<(string, WordTextProperties)> { (data.ProductName, new WordTextProperties { Bold = true, Size = "24", }) }, TextProperties = new WordTextProperties { Size = "24", - JustificationType = WordJustificationType.Both + JustificationType = WordJustificationType.Center } }); foreach (var paymeant in data.Values) { CreateParagraph(new WordParagraph { Texts = new List<(string, WordTextProperties)> { ($"Оплата №:{paymeant.PaymeantID} статус:{paymeant.PaymeantStatus}", - new WordTextProperties { Bold = true, Size = "24", }) }, + new WordTextProperties { Bold = false, Size = "24", }) }, TextProperties = new WordTextProperties { Size = "24", JustificationType = WordJustificationType.Both diff --git a/ElectronicsShop/ElectronicsShopContracts/SearchModels/EmployeeSearchModel.cs b/ElectronicsShop/ElectronicsShopContracts/SearchModels/EmployeeSearchModel.cs index 1387df1..aaf915f 100644 --- a/ElectronicsShop/ElectronicsShopContracts/SearchModels/EmployeeSearchModel.cs +++ b/ElectronicsShop/ElectronicsShopContracts/SearchModels/EmployeeSearchModel.cs @@ -11,7 +11,7 @@ namespace ElectronicsShopContracts.SearchModels { public int? ID { get; set; } public string? EmployeFIO { get; set; } - public string? Login { get; set; } + public string? Email { get; set; } public string? Password { get; set; } } } diff --git a/ElectronicsShop/ElectronicsShopDataBaseImplement/Implements/EmployeeStorage.cs b/ElectronicsShop/ElectronicsShopDataBaseImplement/Implements/EmployeeStorage.cs index 0003bce..39ffdcf 100644 --- a/ElectronicsShop/ElectronicsShopDataBaseImplement/Implements/EmployeeStorage.cs +++ b/ElectronicsShop/ElectronicsShopDataBaseImplement/Implements/EmployeeStorage.cs @@ -52,13 +52,13 @@ namespace ElectronicsShopDataBaseImplement.Implements return context.Employees .FirstOrDefault(x => model.ID.HasValue && x.ID == model.ID)?.GetViewModel; } - else if (!string.IsNullOrEmpty(model.Login) && !string.IsNullOrEmpty(model.Password)) { + else if (!string.IsNullOrEmpty(model.Email) && !string.IsNullOrEmpty(model.Password)) { return context.Employees - .FirstOrDefault(x => (x.Email == model.Login && x.Password == model.Password)) + .FirstOrDefault(x => (x.Email == model.Email && x.Password == model.Password)) ?.GetViewModel; } return context.Employees - .FirstOrDefault(x => (x.Email == model.Login)) + .FirstOrDefault(x => (x.Email == model.Email)) ?.GetViewModel; } @@ -66,7 +66,7 @@ namespace ElectronicsShopDataBaseImplement.Implements { using var context = new Database(); return context.Employees.Where(x => x.Email - .Contains(model.Login)) + .Contains(model.Email)) .Select(x => x.GetViewModel).ToList(); } diff --git a/ElectronicsShop/ElectronicsShopDataBaseImplement/Implements/ProductStorage.cs b/ElectronicsShop/ElectronicsShopDataBaseImplement/Implements/ProductStorage.cs index 124eba0..3fbd4ac 100644 --- a/ElectronicsShop/ElectronicsShopDataBaseImplement/Implements/ProductStorage.cs +++ b/ElectronicsShop/ElectronicsShopDataBaseImplement/Implements/ProductStorage.cs @@ -71,7 +71,9 @@ namespace ElectronicsShopDataBaseImplement.Implements .FirstOrDefault(x => model.CostItemID == x.CostItemID)?.GetViewModel; } - return null; + return context.Products + .Include(x => x.CostItem) + .FirstOrDefault(x => model.ProductName == x.ProductName)?.GetViewModel; } public List? GetFilteredList(ProductSearchModel model) diff --git a/ElectronicsShop/ElectronicsShopDataBaseImplement/Migrations/20240726071024_InitMigration.Designer.cs b/ElectronicsShop/ElectronicsShopDataBaseImplement/Migrations/20240726071024_InitMigration.Designer.cs deleted file mode 100644 index 199ce9a..0000000 --- a/ElectronicsShop/ElectronicsShopDataBaseImplement/Migrations/20240726071024_InitMigration.Designer.cs +++ /dev/null @@ -1,288 +0,0 @@ -// -using System; -using ElectronicsShopDataBaseImplement; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -#nullable disable - -namespace ElectronicsShopDataBaseImplement.Migrations -{ - [DbContext(typeof(Database))] - [Migration("20240726071024_InitMigration")] - partial class InitMigration - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "8.0.4") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); - - modelBuilder.Entity("ElectronicsShopDataBaseImplement.Models.Client", b => - { - b.Property("ID") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ID")); - - b.Property("ClientFIO") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Email") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Password") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.HasKey("ID"); - - b.ToTable("Clients"); - }); - - modelBuilder.Entity("ElectronicsShopDataBaseImplement.Models.CostItem", b => - { - b.Property("ID") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ID")); - - b.Property("CostNum") - .HasColumnType("int"); - - b.Property("EmployeeID") - .HasColumnType("int"); - - b.Property("Name") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Price") - .HasColumnType("float"); - - b.HasKey("ID"); - - b.HasIndex("EmployeeID"); - - b.ToTable("CostItems"); - }); - - modelBuilder.Entity("ElectronicsShopDataBaseImplement.Models.Employee", b => - { - b.Property("ID") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ID")); - - b.Property("EmployeeFIO") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Email") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Password") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.HasKey("ID"); - - b.ToTable("Employees"); - }); - - modelBuilder.Entity("ElectronicsShopDataBaseImplement.Models.Order", b => - { - b.Property("ID") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ID")); - - b.Property("ClientID") - .HasColumnType("int"); - - b.Property("DateCreate") - .HasColumnType("datetime2"); - - b.Property("Status") - .HasColumnType("int"); - - b.Property("Sum") - .HasColumnType("float"); - - b.HasKey("ID"); - - b.HasIndex("ClientID"); - - b.ToTable("Orders"); - }); - - modelBuilder.Entity("ElectronicsShopDataBaseImplement.Models.OrderProduct", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Count") - .HasColumnType("int"); - - b.Property("OrderID") - .HasColumnType("int"); - - b.Property("ProductID") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("OrderID"); - - b.HasIndex("ProductID"); - - b.ToTable("OrderProducts"); - }); - - modelBuilder.Entity("ElectronicsShopDataBaseImplement.Models.Paymeant", b => - { - b.Property("ID") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ID")); - - b.Property("ClientID") - .HasColumnType("int"); - - b.Property("DatePaymeant") - .HasColumnType("datetime2"); - - b.Property("OrderID") - .HasColumnType("int"); - - b.Property("PayOption") - .HasColumnType("int"); - - b.Property("PaymentID") - .HasColumnType("int"); - - b.Property("SumPayment") - .HasColumnType("float"); - - b.HasKey("ID"); - - b.HasIndex("PaymentID"); - - b.ToTable("Paymeants"); - }); - - modelBuilder.Entity("ElectronicsShopDataBaseImplement.Models.Product", b => - { - b.Property("ID") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ID")); - - b.Property("CostItemID") - .HasColumnType("int"); - - b.Property("Price") - .HasColumnType("float"); - - b.Property("ProductName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.HasKey("ID"); - - b.HasIndex("CostItemID"); - - b.ToTable("Products"); - }); - - modelBuilder.Entity("ElectronicsShopDataBaseImplement.Models.CostItem", b => - { - b.HasOne("ElectronicsShopDataBaseImplement.Models.Employee", "Employee") - .WithMany() - .HasForeignKey("EmployeeID") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Employee"); - }); - - modelBuilder.Entity("ElectronicsShopDataBaseImplement.Models.Order", b => - { - b.HasOne("ElectronicsShopDataBaseImplement.Models.Client", null) - .WithMany("Orders") - .HasForeignKey("ClientID") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("ElectronicsShopDataBaseImplement.Models.OrderProduct", b => - { - b.HasOne("ElectronicsShopDataBaseImplement.Models.Order", "_order") - .WithMany("Products") - .HasForeignKey("OrderID") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("ElectronicsShopDataBaseImplement.Models.Product", "_product") - .WithMany() - .HasForeignKey("ProductID") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("_order"); - - b.Navigation("_product"); - }); - - modelBuilder.Entity("ElectronicsShopDataBaseImplement.Models.Paymeant", b => - { - b.HasOne("ElectronicsShopDataBaseImplement.Models.Order", null) - .WithMany("Payments") - .HasForeignKey("PaymentID"); - }); - - modelBuilder.Entity("ElectronicsShopDataBaseImplement.Models.Product", b => - { - b.HasOne("ElectronicsShopDataBaseImplement.Models.CostItem", "CostItem") - .WithMany() - .HasForeignKey("CostItemID") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("CostItem"); - }); - - modelBuilder.Entity("ElectronicsShopDataBaseImplement.Models.Client", b => - { - b.Navigation("Orders"); - }); - - modelBuilder.Entity("ElectronicsShopDataBaseImplement.Models.Order", b => - { - b.Navigation("Payments"); - - b.Navigation("Products"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/ElectronicsShop/ElectronicsShopDataBaseImplement/Migrations/20240727090854_Init.Designer.cs b/ElectronicsShop/ElectronicsShopDataBaseImplement/Migrations/20240727090854_Init.Designer.cs deleted file mode 100644 index e04ab93..0000000 --- a/ElectronicsShop/ElectronicsShopDataBaseImplement/Migrations/20240727090854_Init.Designer.cs +++ /dev/null @@ -1,288 +0,0 @@ -// -using System; -using ElectronicsShopDataBaseImplement; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -#nullable disable - -namespace ElectronicsShopDataBaseImplement.Migrations -{ - [DbContext(typeof(Database))] - [Migration("20240727090854_Init")] - partial class Init - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "8.0.4") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); - - modelBuilder.Entity("ElectronicsShopDataBaseImplement.Models.Client", b => - { - b.Property("ID") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ID")); - - b.Property("ClientFIO") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Email") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Password") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.HasKey("ID"); - - b.ToTable("Clients"); - }); - - modelBuilder.Entity("ElectronicsShopDataBaseImplement.Models.CostItem", b => - { - b.Property("ID") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ID")); - - b.Property("CostNum") - .HasColumnType("int"); - - b.Property("EmployeeID") - .HasColumnType("int"); - - b.Property("Name") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Price") - .HasColumnType("float"); - - b.HasKey("ID"); - - b.HasIndex("EmployeeID"); - - b.ToTable("CostItems"); - }); - - modelBuilder.Entity("ElectronicsShopDataBaseImplement.Models.Employee", b => - { - b.Property("ID") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ID")); - - b.Property("EmployeeFIO") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Email") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Password") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.HasKey("ID"); - - b.ToTable("Employees"); - }); - - modelBuilder.Entity("ElectronicsShopDataBaseImplement.Models.Order", b => - { - b.Property("ID") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ID")); - - b.Property("ClientID") - .HasColumnType("int"); - - b.Property("DateCreate") - .HasColumnType("datetime2"); - - b.Property("Status") - .HasColumnType("int"); - - b.Property("Sum") - .HasColumnType("float"); - - b.HasKey("ID"); - - b.HasIndex("ClientID"); - - b.ToTable("Orders"); - }); - - modelBuilder.Entity("ElectronicsShopDataBaseImplement.Models.OrderProduct", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Count") - .HasColumnType("int"); - - b.Property("OrderID") - .HasColumnType("int"); - - b.Property("ProductID") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("OrderID"); - - b.HasIndex("ProductID"); - - b.ToTable("OrderProducts"); - }); - - modelBuilder.Entity("ElectronicsShopDataBaseImplement.Models.Paymeant", b => - { - b.Property("ID") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ID")); - - b.Property("ClientID") - .HasColumnType("int"); - - b.Property("DatePaymeant") - .HasColumnType("datetime2"); - - b.Property("OrderID") - .HasColumnType("int"); - - b.Property("PayOption") - .HasColumnType("int"); - - b.Property("PaymentID") - .HasColumnType("int"); - - b.Property("SumPayment") - .HasColumnType("float"); - - b.HasKey("ID"); - - b.HasIndex("PaymentID"); - - b.ToTable("Paymeants"); - }); - - modelBuilder.Entity("ElectronicsShopDataBaseImplement.Models.Product", b => - { - b.Property("ID") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ID")); - - b.Property("CostItemID") - .HasColumnType("int"); - - b.Property("Price") - .HasColumnType("float"); - - b.Property("ProductName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.HasKey("ID"); - - b.HasIndex("CostItemID"); - - b.ToTable("Products"); - }); - - modelBuilder.Entity("ElectronicsShopDataBaseImplement.Models.CostItem", b => - { - b.HasOne("ElectronicsShopDataBaseImplement.Models.Employee", "Employee") - .WithMany() - .HasForeignKey("EmployeeID") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Employee"); - }); - - modelBuilder.Entity("ElectronicsShopDataBaseImplement.Models.Order", b => - { - b.HasOne("ElectronicsShopDataBaseImplement.Models.Client", null) - .WithMany("Orders") - .HasForeignKey("ClientID") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("ElectronicsShopDataBaseImplement.Models.OrderProduct", b => - { - b.HasOne("ElectronicsShopDataBaseImplement.Models.Order", "_order") - .WithMany("Products") - .HasForeignKey("OrderID") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("ElectronicsShopDataBaseImplement.Models.Product", "_product") - .WithMany() - .HasForeignKey("ProductID") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("_order"); - - b.Navigation("_product"); - }); - - modelBuilder.Entity("ElectronicsShopDataBaseImplement.Models.Paymeant", b => - { - b.HasOne("ElectronicsShopDataBaseImplement.Models.Order", null) - .WithMany("Payments") - .HasForeignKey("PaymentID"); - }); - - modelBuilder.Entity("ElectronicsShopDataBaseImplement.Models.Product", b => - { - b.HasOne("ElectronicsShopDataBaseImplement.Models.CostItem", "CostItem") - .WithMany() - .HasForeignKey("CostItemID") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("CostItem"); - }); - - modelBuilder.Entity("ElectronicsShopDataBaseImplement.Models.Client", b => - { - b.Navigation("Orders"); - }); - - modelBuilder.Entity("ElectronicsShopDataBaseImplement.Models.Order", b => - { - b.Navigation("Payments"); - - b.Navigation("Products"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/ElectronicsShop/ElectronicsShopDataBaseImplement/Migrations/20240727090854_Init.cs b/ElectronicsShop/ElectronicsShopDataBaseImplement/Migrations/20240727090854_Init.cs deleted file mode 100644 index a527552..0000000 --- a/ElectronicsShop/ElectronicsShopDataBaseImplement/Migrations/20240727090854_Init.cs +++ /dev/null @@ -1,215 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace ElectronicsShopDataBaseImplement.Migrations -{ - /// - public partial class Init : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "Clients", - columns: table => new - { - ID = table.Column(type: "int", nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), - ClientFIO = table.Column(type: "nvarchar(max)", nullable: false), - Password = table.Column(type: "nvarchar(max)", nullable: false), - Email = table.Column(type: "nvarchar(max)", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Clients", x => x.ID); - }); - - migrationBuilder.CreateTable( - name: "Employees", - columns: table => new - { - ID = table.Column(type: "int", nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), - EmployeeFIO = table.Column(type: "nvarchar(max)", nullable: false), - Login = table.Column(type: "nvarchar(max)", nullable: false), - Password = table.Column(type: "nvarchar(max)", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Employees", x => x.ID); - }); - - migrationBuilder.CreateTable( - name: "Orders", - columns: table => new - { - ID = table.Column(type: "int", nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), - Sum = table.Column(type: "float", nullable: false), - ClientID = table.Column(type: "int", nullable: false), - DateCreate = table.Column(type: "datetime2", nullable: false), - Status = table.Column(type: "int", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Orders", x => x.ID); - table.ForeignKey( - name: "FK_Orders_Clients_ClientID", - column: x => x.ClientID, - principalTable: "Clients", - principalColumn: "ID", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "CostItems", - columns: table => new - { - ID = table.Column(type: "int", nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), - EmployeeID = table.Column(type: "int", nullable: false), - Name = table.Column(type: "nvarchar(max)", nullable: false), - Price = table.Column(type: "float", nullable: false), - CostNum = table.Column(type: "int", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_CostItems", x => x.ID); - table.ForeignKey( - name: "FK_CostItems_Employees_EmployeeID", - column: x => x.EmployeeID, - principalTable: "Employees", - principalColumn: "ID", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "Paymeants", - columns: table => new - { - ID = table.Column(type: "int", nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), - OrderID = table.Column(type: "int", nullable: false), - ClientID = table.Column(type: "int", nullable: false), - SumPayment = table.Column(type: "float", nullable: false), - PayOption = table.Column(type: "int", nullable: false), - DatePaymeant = table.Column(type: "datetime2", nullable: false), - PaymentID = table.Column(type: "int", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_Paymeants", x => x.ID); - table.ForeignKey( - name: "FK_Paymeants_Orders_PaymentID", - column: x => x.PaymentID, - principalTable: "Orders", - principalColumn: "ID"); - }); - - migrationBuilder.CreateTable( - name: "Products", - columns: table => new - { - ID = table.Column(type: "int", nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), - ProductName = table.Column(type: "nvarchar(max)", nullable: false), - Price = table.Column(type: "float", nullable: false), - CostItemID = table.Column(type: "int", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Products", x => x.ID); - table.ForeignKey( - name: "FK_Products_CostItems_CostItemID", - column: x => x.CostItemID, - principalTable: "CostItems", - principalColumn: "ID", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "OrderProducts", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), - OrderID = table.Column(type: "int", nullable: false), - ProductID = table.Column(type: "int", nullable: false), - Count = table.Column(type: "int", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_OrderProducts", x => x.Id); - table.ForeignKey( - name: "FK_OrderProducts_Orders_OrderID", - column: x => x.OrderID, - principalTable: "Orders", - principalColumn: "ID", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_OrderProducts_Products_ProductID", - column: x => x.ProductID, - principalTable: "Products", - principalColumn: "ID", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateIndex( - name: "IX_CostItems_EmployeeID", - table: "CostItems", - column: "EmployeeID"); - - migrationBuilder.CreateIndex( - name: "IX_OrderProducts_OrderID", - table: "OrderProducts", - column: "OrderID"); - - migrationBuilder.CreateIndex( - name: "IX_OrderProducts_ProductID", - table: "OrderProducts", - column: "ProductID"); - - migrationBuilder.CreateIndex( - name: "IX_Orders_ClientID", - table: "Orders", - column: "ClientID"); - - migrationBuilder.CreateIndex( - name: "IX_Paymeants_PaymentID", - table: "Paymeants", - column: "PaymentID"); - - migrationBuilder.CreateIndex( - name: "IX_Products_CostItemID", - table: "Products", - column: "CostItemID"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "OrderProducts"); - - migrationBuilder.DropTable( - name: "Paymeants"); - - migrationBuilder.DropTable( - name: "Products"); - - migrationBuilder.DropTable( - name: "Orders"); - - migrationBuilder.DropTable( - name: "CostItems"); - - migrationBuilder.DropTable( - name: "Clients"); - - migrationBuilder.DropTable( - name: "Employees"); - } - } -} diff --git a/ElectronicsShop/ElectronicsShopDataBaseImplement/Migrations/20240727100624_Migration01.cs b/ElectronicsShop/ElectronicsShopDataBaseImplement/Migrations/20240727100624_Migration01.cs deleted file mode 100644 index c6d155e..0000000 --- a/ElectronicsShop/ElectronicsShopDataBaseImplement/Migrations/20240727100624_Migration01.cs +++ /dev/null @@ -1,48 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace ElectronicsShopDataBaseImplement.Migrations -{ - /// - public partial class Migration01 : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropForeignKey( - name: "FK_Paymeants_Orders_PaymentID", - table: "Paymeants"); - - migrationBuilder.DropIndex( - name: "IX_Paymeants_PaymentID", - table: "Paymeants"); - - migrationBuilder.DropColumn( - name: "PaymentID", - table: "Paymeants"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "PaymentID", - table: "Paymeants", - type: "int", - nullable: true); - - migrationBuilder.CreateIndex( - name: "IX_Paymeants_PaymentID", - table: "Paymeants", - column: "PaymentID"); - - migrationBuilder.AddForeignKey( - name: "FK_Paymeants_Orders_PaymentID", - table: "Paymeants", - column: "PaymentID", - principalTable: "Orders", - principalColumn: "ID"); - } - } -} diff --git a/ElectronicsShop/ElectronicsShopDataBaseImplement/Migrations/20240727100624_Migration01.Designer.cs b/ElectronicsShop/ElectronicsShopDataBaseImplement/Migrations/20240803184800_InitMigration.Designer.cs similarity index 99% rename from ElectronicsShop/ElectronicsShopDataBaseImplement/Migrations/20240727100624_Migration01.Designer.cs rename to ElectronicsShop/ElectronicsShopDataBaseImplement/Migrations/20240803184800_InitMigration.Designer.cs index b30636b..7626fbc 100644 --- a/ElectronicsShop/ElectronicsShopDataBaseImplement/Migrations/20240727100624_Migration01.Designer.cs +++ b/ElectronicsShop/ElectronicsShopDataBaseImplement/Migrations/20240803184800_InitMigration.Designer.cs @@ -12,8 +12,8 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion; namespace ElectronicsShopDataBaseImplement.Migrations { [DbContext(typeof(Database))] - [Migration("20240727100624_Migration01")] - partial class Migration01 + [Migration("20240803184800_InitMigration")] + partial class InitMigration { /// protected override void BuildTargetModel(ModelBuilder modelBuilder) @@ -86,11 +86,11 @@ namespace ElectronicsShopDataBaseImplement.Migrations SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ID")); - b.Property("EmployeeFIO") + b.Property("Email") .IsRequired() .HasColumnType("nvarchar(max)"); - b.Property("Email") + b.Property("EmployeeFIO") .IsRequired() .HasColumnType("nvarchar(max)"); diff --git a/ElectronicsShop/ElectronicsShopDataBaseImplement/Migrations/20240726071024_InitMigration.cs b/ElectronicsShop/ElectronicsShopDataBaseImplement/Migrations/20240803184800_InitMigration.cs similarity index 93% rename from ElectronicsShop/ElectronicsShopDataBaseImplement/Migrations/20240726071024_InitMigration.cs rename to ElectronicsShop/ElectronicsShopDataBaseImplement/Migrations/20240803184800_InitMigration.cs index af81095..9e13702 100644 --- a/ElectronicsShop/ElectronicsShopDataBaseImplement/Migrations/20240726071024_InitMigration.cs +++ b/ElectronicsShop/ElectronicsShopDataBaseImplement/Migrations/20240803184800_InitMigration.cs @@ -33,7 +33,7 @@ namespace ElectronicsShopDataBaseImplement.Migrations ID = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), EmployeeFIO = table.Column(type: "nvarchar(max)", nullable: false), - Login = table.Column(type: "nvarchar(max)", nullable: false), + Email = table.Column(type: "nvarchar(max)", nullable: false), Password = table.Column(type: "nvarchar(max)", nullable: false) }, constraints: table => @@ -41,6 +41,23 @@ namespace ElectronicsShopDataBaseImplement.Migrations table.PrimaryKey("PK_Employees", x => x.ID); }); + migrationBuilder.CreateTable( + name: "Paymeants", + columns: table => new + { + ID = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + OrderID = table.Column(type: "int", nullable: false), + ClientID = table.Column(type: "int", nullable: false), + SumPayment = table.Column(type: "float", nullable: false), + PayOption = table.Column(type: "int", nullable: false), + DatePaymeant = table.Column(type: "datetime2", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Paymeants", x => x.ID); + }); + migrationBuilder.CreateTable( name: "Orders", columns: table => new @@ -85,29 +102,6 @@ namespace ElectronicsShopDataBaseImplement.Migrations onDelete: ReferentialAction.Cascade); }); - migrationBuilder.CreateTable( - name: "Paymeants", - columns: table => new - { - ID = table.Column(type: "int", nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), - OrderID = table.Column(type: "int", nullable: false), - ClientID = table.Column(type: "int", nullable: false), - SumPayment = table.Column(type: "float", nullable: false), - PayOption = table.Column(type: "int", nullable: false), - DatePaymeant = table.Column(type: "datetime2", nullable: false), - PaymentID = table.Column(type: "int", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_Paymeants", x => x.ID); - table.ForeignKey( - name: "FK_Paymeants_Orders_PaymentID", - column: x => x.PaymentID, - principalTable: "Orders", - principalColumn: "ID"); - }); - migrationBuilder.CreateTable( name: "Products", columns: table => new @@ -176,11 +170,6 @@ namespace ElectronicsShopDataBaseImplement.Migrations table: "Orders", column: "ClientID"); - migrationBuilder.CreateIndex( - name: "IX_Paymeants_PaymentID", - table: "Paymeants", - column: "PaymentID"); - migrationBuilder.CreateIndex( name: "IX_Products_CostItemID", table: "Products", @@ -196,18 +185,18 @@ namespace ElectronicsShopDataBaseImplement.Migrations migrationBuilder.DropTable( name: "Paymeants"); - migrationBuilder.DropTable( - name: "Products"); - migrationBuilder.DropTable( name: "Orders"); migrationBuilder.DropTable( - name: "CostItems"); + name: "Products"); migrationBuilder.DropTable( name: "Clients"); + migrationBuilder.DropTable( + name: "CostItems"); + migrationBuilder.DropTable( name: "Employees"); } diff --git a/ElectronicsShop/ElectronicsShopDataBaseImplement/Migrations/DatabaseModelSnapshot.cs b/ElectronicsShop/ElectronicsShopDataBaseImplement/Migrations/DatabaseModelSnapshot.cs index d79aa8d..83facd9 100644 --- a/ElectronicsShop/ElectronicsShopDataBaseImplement/Migrations/DatabaseModelSnapshot.cs +++ b/ElectronicsShop/ElectronicsShopDataBaseImplement/Migrations/DatabaseModelSnapshot.cs @@ -83,11 +83,11 @@ namespace ElectronicsShopDataBaseImplement.Migrations SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ID")); - b.Property("EmployeeFIO") + b.Property("Email") .IsRequired() .HasColumnType("nvarchar(max)"); - b.Property("Email") + b.Property("EmployeeFIO") .IsRequired() .HasColumnType("nvarchar(max)"); diff --git a/ElectronicsShop/ElectronicsShopRestAPI/Controllers/EmployeeController.cs b/ElectronicsShop/ElectronicsShopRestAPI/Controllers/EmployeeController.cs index d473994..9d5fbb8 100644 --- a/ElectronicsShop/ElectronicsShopRestAPI/Controllers/EmployeeController.cs +++ b/ElectronicsShop/ElectronicsShopRestAPI/Controllers/EmployeeController.cs @@ -34,7 +34,7 @@ namespace ElectronicsShopRestAPI.Controllers { public EmployeeViewModel? Login(string login, string password) { try { return _logic.ReadElement(new EmployeeSearchModel { - Login = login, + Email = login, Password = password }); } diff --git a/ElectronicsShop/ElectronicsShopRestAPI/Report b/ElectronicsShop/ElectronicsShopRestAPI/Report index 45a2ab8..3d80497 100644 Binary files a/ElectronicsShop/ElectronicsShopRestAPI/Report and b/ElectronicsShop/ElectronicsShopRestAPI/Report differ diff --git a/ElectronicsShop/ElectronicsShopShopClientApp/Controllers/HomeController.cs b/ElectronicsShop/ElectronicsShopShopClientApp/Controllers/HomeController.cs index 24124fd..ec144c0 100644 --- a/ElectronicsShop/ElectronicsShopShopClientApp/Controllers/HomeController.cs +++ b/ElectronicsShop/ElectronicsShopShopClientApp/Controllers/HomeController.cs @@ -1,4 +1,5 @@ using DocumentFormat.OpenXml.Bibliography; +using DocumentFormat.OpenXml.Spreadsheet; using ElectronicsShopContracts.BindingModels; using ElectronicsShopContracts.BusinessLogicContracts; using ElectronicsShopContracts.SearchModels; @@ -78,8 +79,8 @@ namespace ElectronicsShopUserApp.Controllers { public void Enter(string email, string password) { if (string.IsNullOrEmpty(email) || string.IsNullOrEmpty(password)) { throw new Exception(" "); - } - APIClient.Client = APIClient.GetRequset($"api/Client/Email?email={email}&password={password}"); + } + APIClient.Client = APIClient.GetRequset($"api/Client/Login?email={email}&password={password}"); if (APIClient.Client == null) { throw new Exception(" /"); }