This commit is contained in:
Илья Федотов 2024-05-27 14:57:41 +04:00
parent e07a12bf92
commit 1dd398772a
19 changed files with 630 additions and 99 deletions

View File

@ -11,14 +11,14 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ElectronicsShopBusinessLogi
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ElectronicsShopDataBaseImplement", "ElectronicsShopDataBaseImplement\ElectronicsShopDataBaseImplement.csproj", "{03442D38-4C09-49D1-85F3-F8F563072F9B}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ElectronicsShopDataBaseImplement", "ElectronicsShopDataBaseImplement\ElectronicsShopDataBaseImplement.csproj", "{03442D38-4C09-49D1-85F3-F8F563072F9B}"
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ElectronicsShopRestAPI", "ElectronicsShopResrAPI\ElectronicsShopRestAPI.csproj", "{BDEC8526-DB9D-49F3-93B5-8777339CC040}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ElectronicsShopClientApp", "ElectronicsShopClientApp\ElectronicsShopClientApp.csproj", "{6EDC1439-C558-46A4-BFF9-3BA3B66044C7}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ElectronicsShopClientApp", "ElectronicsShopClientApp\ElectronicsShopClientApp.csproj", "{6EDC1439-C558-46A4-BFF9-3BA3B66044C7}"
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ElectronicsShopShopClientApp", "ElectronicsShopShopClientApp\ElectronicsShopShopClientApp.csproj", "{029A15C5-BBCE-415E-A3EC-80568D54852A}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ElectronicsShopShopClientApp", "ElectronicsShopShopClientApp\ElectronicsShopShopClientApp.csproj", "{029A15C5-BBCE-415E-A3EC-80568D54852A}"
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ElectronicsShopEmployeeApp", "ElectronicsShopEmployeeApp\ElectronicsShopEmployeeApp.csproj", "{EEDB8074-33B3-409C-A3DD-AF6B403CC907}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ElectronicsShopEmployeeApp", "ElectronicsShopEmployeeApp\ElectronicsShopEmployeeApp.csproj", "{EEDB8074-33B3-409C-A3DD-AF6B403CC907}"
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ElectronicsShopRestAPI", "ElectronicsShopRestAPI\ElectronicsShopRestAPI.csproj", "{BCC79812-AE38-45C2-9A2A-87A24827FA48}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
@ -41,10 +41,6 @@ Global
{03442D38-4C09-49D1-85F3-F8F563072F9B}.Debug|Any CPU.Build.0 = Debug|Any CPU {03442D38-4C09-49D1-85F3-F8F563072F9B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{03442D38-4C09-49D1-85F3-F8F563072F9B}.Release|Any CPU.ActiveCfg = Release|Any CPU {03442D38-4C09-49D1-85F3-F8F563072F9B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{03442D38-4C09-49D1-85F3-F8F563072F9B}.Release|Any CPU.Build.0 = Release|Any CPU {03442D38-4C09-49D1-85F3-F8F563072F9B}.Release|Any CPU.Build.0 = Release|Any CPU
{BDEC8526-DB9D-49F3-93B5-8777339CC040}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BDEC8526-DB9D-49F3-93B5-8777339CC040}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BDEC8526-DB9D-49F3-93B5-8777339CC040}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BDEC8526-DB9D-49F3-93B5-8777339CC040}.Release|Any CPU.Build.0 = Release|Any CPU
{6EDC1439-C558-46A4-BFF9-3BA3B66044C7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {6EDC1439-C558-46A4-BFF9-3BA3B66044C7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6EDC1439-C558-46A4-BFF9-3BA3B66044C7}.Debug|Any CPU.Build.0 = Debug|Any CPU {6EDC1439-C558-46A4-BFF9-3BA3B66044C7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6EDC1439-C558-46A4-BFF9-3BA3B66044C7}.Release|Any CPU.ActiveCfg = Release|Any CPU {6EDC1439-C558-46A4-BFF9-3BA3B66044C7}.Release|Any CPU.ActiveCfg = Release|Any CPU
@ -57,6 +53,10 @@ Global
{EEDB8074-33B3-409C-A3DD-AF6B403CC907}.Debug|Any CPU.Build.0 = Debug|Any CPU {EEDB8074-33B3-409C-A3DD-AF6B403CC907}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EEDB8074-33B3-409C-A3DD-AF6B403CC907}.Release|Any CPU.ActiveCfg = Release|Any CPU {EEDB8074-33B3-409C-A3DD-AF6B403CC907}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EEDB8074-33B3-409C-A3DD-AF6B403CC907}.Release|Any CPU.Build.0 = Release|Any CPU {EEDB8074-33B3-409C-A3DD-AF6B403CC907}.Release|Any CPU.Build.0 = Release|Any CPU
{BCC79812-AE38-45C2-9A2A-87A24827FA48}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BCC79812-AE38-45C2-9A2A-87A24827FA48}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BCC79812-AE38-45C2-9A2A-87A24827FA48}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BCC79812-AE38-45C2-9A2A-87A24827FA48}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE

View File

@ -12,7 +12,7 @@ using System.Threading.Tasks;
namespace ElectronicsShopBusinessLogic.BusinessLogic namespace ElectronicsShopBusinessLogic.BusinessLogic
{ {
internal class ClientLogic : IClientLogic public class ClientLogic : IClientLogic
{ {
private readonly ILogger _logger; private readonly ILogger _logger;
private readonly IClientStorage _storage; private readonly IClientStorage _storage;
@ -113,7 +113,7 @@ namespace ElectronicsShopBusinessLogic.BusinessLogic
{ {
Email= model.Email Email= model.Email
}); });
if (element != null && element.Email != model.Email) if (element != null && element.Email == model.Email)
{ {
throw new InvalidOperationException("Клиент с такой почтой уже есть"); throw new InvalidOperationException("Клиент с такой почтой уже есть");
} }

View File

@ -12,5 +12,6 @@ namespace ElectronicsShopContracts.SearchModels
public int? ID { get; set; } public int? ID { get; set; }
public string? EmployeFIO { get; set; } public string? EmployeFIO { get; set; }
public string? Login { get; set; } public string? Login { get; set; }
public string? Password { get; set; }
} }
} }

View File

@ -0,0 +1,254 @@
// <auto-generated />
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("20240526155227_Migration02")]
partial class Migration02
{
/// <inheritdoc />
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<int>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
b.Property<string>("ClientFIO")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Email")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Password")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("ID");
b.ToTable("Clients");
});
modelBuilder.Entity("ElectronicsShopDataBaseImplement.Models.CostItem", b =>
{
b.Property<int>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
b.Property<int>("EmployeeID")
.HasColumnType("int");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<double>("Price")
.HasColumnType("float");
b.HasKey("ID");
b.ToTable("CostItems");
});
modelBuilder.Entity("ElectronicsShopDataBaseImplement.Models.Employee", b =>
{
b.Property<int>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
b.Property<string>("EmployeeFIO")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Login")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Password")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("ID");
b.ToTable("Employees");
});
modelBuilder.Entity("ElectronicsShopDataBaseImplement.Models.Order", b =>
{
b.Property<int>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
b.Property<int>("ClientID")
.HasColumnType("int");
b.Property<DateTime>("DateCreate")
.HasColumnType("datetime2");
b.Property<double>("Sum")
.HasColumnType("float");
b.HasKey("ID");
b.HasIndex("ClientID");
b.ToTable("Orders");
});
modelBuilder.Entity("ElectronicsShopDataBaseImplement.Models.OrderProduct", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("Count")
.HasColumnType("int");
b.Property<int>("OrderID")
.HasColumnType("int");
b.Property<int>("ProductID")
.HasColumnType("int");
b.Property<int?>("_productID")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("ProductID");
b.HasIndex("_productID");
b.ToTable("OrderProducts");
});
modelBuilder.Entity("ElectronicsShopDataBaseImplement.Models.Paymeant", b =>
{
b.Property<int>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
b.Property<int>("OrderID")
.HasColumnType("int");
b.Property<int>("PayOption")
.HasColumnType("int");
b.Property<int?>("PaymentID")
.HasColumnType("int");
b.Property<int>("ProductID")
.HasColumnType("int");
b.Property<double>("SumPayment")
.HasColumnType("float");
b.HasKey("ID");
b.HasIndex("PaymentID");
b.ToTable("Paymeants");
});
modelBuilder.Entity("ElectronicsShopDataBaseImplement.Models.Product", b =>
{
b.Property<int>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
b.Property<int>("CostItemID")
.HasColumnType("int");
b.Property<double>("Price")
.HasColumnType("float");
b.Property<string>("ProductName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("ID");
b.ToTable("Products");
});
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("ProductID")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("ElectronicsShopDataBaseImplement.Models.Product", "_product")
.WithMany()
.HasForeignKey("_productID");
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.Client", b =>
{
b.Navigation("Orders");
});
modelBuilder.Entity("ElectronicsShopDataBaseImplement.Models.Order", b =>
{
b.Navigation("Payments");
b.Navigation("Products");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,175 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace ElectronicsShopDataBaseImplement.Migrations
{
/// <inheritdoc />
public partial class Migration02 : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_OrderProducts_Orders__orderID",
table: "OrderProducts");
migrationBuilder.DropForeignKey(
name: "FK_OrderProducts_Products_ProductID",
table: "OrderProducts");
migrationBuilder.DropIndex(
name: "IX_OrderProducts__orderID",
table: "OrderProducts");
migrationBuilder.DropColumn(
name: "EmployeeID",
table: "Orders");
migrationBuilder.DropColumn(
name: "OrdersID",
table: "OrderProducts");
migrationBuilder.RenameColumn(
name: "_orderID",
table: "OrderProducts",
newName: "OrderID");
migrationBuilder.AddColumn<int>(
name: "_productID",
table: "OrderProducts",
type: "int",
nullable: true);
migrationBuilder.CreateTable(
name: "Paymeants",
columns: table => new
{
ID = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
ProductID = table.Column<int>(type: "int", nullable: false),
OrderID = table.Column<int>(type: "int", nullable: false),
SumPayment = table.Column<double>(type: "float", nullable: false),
PayOption = table.Column<int>(type: "int", nullable: false),
PaymentID = table.Column<int>(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.CreateIndex(
name: "IX_Orders_ClientID",
table: "Orders",
column: "ClientID");
migrationBuilder.CreateIndex(
name: "IX_OrderProducts__productID",
table: "OrderProducts",
column: "_productID");
migrationBuilder.CreateIndex(
name: "IX_Paymeants_PaymentID",
table: "Paymeants",
column: "PaymentID");
migrationBuilder.AddForeignKey(
name: "FK_OrderProducts_Orders_ProductID",
table: "OrderProducts",
column: "ProductID",
principalTable: "Orders",
principalColumn: "ID",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_OrderProducts_Products__productID",
table: "OrderProducts",
column: "_productID",
principalTable: "Products",
principalColumn: "ID");
migrationBuilder.AddForeignKey(
name: "FK_Orders_Clients_ClientID",
table: "Orders",
column: "ClientID",
principalTable: "Clients",
principalColumn: "ID",
onDelete: ReferentialAction.Cascade);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_OrderProducts_Orders_ProductID",
table: "OrderProducts");
migrationBuilder.DropForeignKey(
name: "FK_OrderProducts_Products__productID",
table: "OrderProducts");
migrationBuilder.DropForeignKey(
name: "FK_Orders_Clients_ClientID",
table: "Orders");
migrationBuilder.DropTable(
name: "Paymeants");
migrationBuilder.DropIndex(
name: "IX_Orders_ClientID",
table: "Orders");
migrationBuilder.DropIndex(
name: "IX_OrderProducts__productID",
table: "OrderProducts");
migrationBuilder.DropColumn(
name: "_productID",
table: "OrderProducts");
migrationBuilder.RenameColumn(
name: "OrderID",
table: "OrderProducts",
newName: "_orderID");
migrationBuilder.AddColumn<int>(
name: "EmployeeID",
table: "Orders",
type: "int",
nullable: true);
migrationBuilder.AddColumn<int>(
name: "OrdersID",
table: "OrderProducts",
type: "int",
nullable: false,
defaultValue: 0);
migrationBuilder.CreateIndex(
name: "IX_OrderProducts__orderID",
table: "OrderProducts",
column: "_orderID");
migrationBuilder.AddForeignKey(
name: "FK_OrderProducts_Orders__orderID",
table: "OrderProducts",
column: "_orderID",
principalTable: "Orders",
principalColumn: "ID",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_OrderProducts_Products_ProductID",
table: "OrderProducts",
column: "ProductID",
principalTable: "Products",
principalColumn: "ID",
onDelete: ReferentialAction.Cascade);
}
}
}

View File

@ -109,14 +109,13 @@ namespace ElectronicsShopDataBaseImplement.Migrations
b.Property<DateTime>("DateCreate") b.Property<DateTime>("DateCreate")
.HasColumnType("datetime2"); .HasColumnType("datetime2");
b.Property<int?>("EmployeeID")
.HasColumnType("int");
b.Property<double>("Sum") b.Property<double>("Sum")
.HasColumnType("float"); .HasColumnType("float");
b.HasKey("ID"); b.HasKey("ID");
b.HasIndex("ClientID");
b.ToTable("Orders"); b.ToTable("Orders");
}); });
@ -131,24 +130,54 @@ namespace ElectronicsShopDataBaseImplement.Migrations
b.Property<int>("Count") b.Property<int>("Count")
.HasColumnType("int"); .HasColumnType("int");
b.Property<int>("OrdersID") b.Property<int>("OrderID")
.HasColumnType("int"); .HasColumnType("int");
b.Property<int>("ProductID") b.Property<int>("ProductID")
.HasColumnType("int"); .HasColumnType("int");
b.Property<int>("_orderID") b.Property<int?>("_productID")
.HasColumnType("int"); .HasColumnType("int");
b.HasKey("Id"); b.HasKey("Id");
b.HasIndex("ProductID"); b.HasIndex("ProductID");
b.HasIndex("_orderID"); b.HasIndex("_productID");
b.ToTable("OrderProducts"); b.ToTable("OrderProducts");
}); });
modelBuilder.Entity("ElectronicsShopDataBaseImplement.Models.Paymeant", b =>
{
b.Property<int>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
b.Property<int>("OrderID")
.HasColumnType("int");
b.Property<int>("PayOption")
.HasColumnType("int");
b.Property<int?>("PaymentID")
.HasColumnType("int");
b.Property<int>("ProductID")
.HasColumnType("int");
b.Property<double>("SumPayment")
.HasColumnType("float");
b.HasKey("ID");
b.HasIndex("PaymentID");
b.ToTable("Paymeants");
});
modelBuilder.Entity("ElectronicsShopDataBaseImplement.Models.Product", b => modelBuilder.Entity("ElectronicsShopDataBaseImplement.Models.Product", b =>
{ {
b.Property<int>("ID") b.Property<int>("ID")
@ -172,27 +201,48 @@ namespace ElectronicsShopDataBaseImplement.Migrations
b.ToTable("Products"); b.ToTable("Products");
}); });
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 => modelBuilder.Entity("ElectronicsShopDataBaseImplement.Models.OrderProduct", b =>
{ {
b.HasOne("ElectronicsShopDataBaseImplement.Models.Product", "_product") b.HasOne("ElectronicsShopDataBaseImplement.Models.Order", "_order")
.WithMany() .WithMany("Products")
.HasForeignKey("ProductID") .HasForeignKey("ProductID")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.IsRequired(); .IsRequired();
b.HasOne("ElectronicsShopDataBaseImplement.Models.Order", "_order") b.HasOne("ElectronicsShopDataBaseImplement.Models.Product", "_product")
.WithMany("Products") .WithMany()
.HasForeignKey("_orderID") .HasForeignKey("_productID");
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("_order"); b.Navigation("_order");
b.Navigation("_product"); b.Navigation("_product");
}); });
modelBuilder.Entity("ElectronicsShopDataBaseImplement.Models.Paymeant", b =>
{
b.HasOne("ElectronicsShopDataBaseImplement.Models.Order", null)
.WithMany("Payments")
.HasForeignKey("PaymentID");
});
modelBuilder.Entity("ElectronicsShopDataBaseImplement.Models.Client", b =>
{
b.Navigation("Orders");
});
modelBuilder.Entity("ElectronicsShopDataBaseImplement.Models.Order", b => modelBuilder.Entity("ElectronicsShopDataBaseImplement.Models.Order", b =>
{ {
b.Navigation("Payments");
b.Navigation("Products"); b.Navigation("Products");
}); });
#pragma warning restore 612, 618 #pragma warning restore 612, 618

View File

@ -11,19 +11,16 @@ namespace ElectronicsShopDataBaseImplement.Models
public class OrderProduct public class OrderProduct
{ {
public int Id { get; set; } public int Id { get; set; }
[ForeignKey("OrderID")]
public int OrdersID { get; set; }
[ForeignKey("ProductID")] public int OrderID { get; set; }
public int ProductID { get; set; } public int ProductID { get; set; }
[Required] [Required]
public int Count { get; set; } public int Count { get; set; }
[ForeignKey("OrderID")]
public virtual Order _order { get; set; } = new(); public virtual Order _order { get; set; } = new();
[ForeignKey("ProductID")]
public virtual Product _product { get; set; } = new(); public virtual Product _product { get; set; } = new();
} }
} }

View File

@ -1,33 +0,0 @@
using ElectronicsShopContracts.BindingModels;
using ElectronicsShopContracts.ViewModels;
using Microsoft.AspNetCore.Mvc;
namespace ElectronicsShopRestAPI.Controllers {
[Route("api/[controller]/[action]")]
[ApiController]
public class ClientController : Controller {
private readonly ILogger _logger;
public ClientController(ILogger<ClientController> logger) {
_logger = logger;
}
[HttpGet]
public ClientViewModel? Login(string email, string password) {
return null;
}
[HttpPost]
public void Register(ClientBindingModel model) {
return;
}
[HttpPost]
public void UpdateData(ClientBindingModel model) {
return;
}
}
}

View File

@ -1,33 +0,0 @@
using ElectronicsShopContracts.BindingModels;
using ElectronicsShopContracts.ViewModels;
using Microsoft.AspNetCore.Mvc;
namespace ElectronicsShopRestAPI.Controllers {
[Route("api/[controller]/[action]")]
[ApiController]
public class EmployeeController : Controller {
private readonly ILogger _logger;
public EmployeeController(ILogger<EmployeeController> logger) {
_logger = logger;
}
[HttpGet]
public EmployeeViewModel? Login(string login, string password) {
return null;
}
[HttpPost]
public void Register(EmployeeBindingModel model) {
return;
}
[HttpPost]
public void UpdateData(EmployeeBindingModel model) {
return;
}
}
}

View File

@ -0,0 +1,58 @@
using ElectronicsShopContracts.BindingModels;
using ElectronicsShopContracts.BusinessLogicContracts;
using ElectronicsShopContracts.SearchModels;
using ElectronicsShopContracts.ViewModels;
using Microsoft.AspNetCore.Mvc;
namespace ElectronicsShopRestAPI.Controllers {
[Route("api/[controller]/[action]")]
[ApiController]
public class ClientController : Controller {
private readonly ILogger _logger;
private readonly IClientLogic _logic;
public ClientController(ILogger<ClientController> logger, IClientLogic logic) {
_logger = logger;
_logic = logic;
}
[HttpGet]
public ClientViewModel? Login(string email, string password) {
try {
return _logic.ReadElemet(new ClientSearchModel {
Email = email,
Passwrod = password
});
}
catch (Exception ex) {
_logger.LogError(ex, "Ошибка входа в систему");
throw;
}
}
[HttpPost]
public void Register(ClientBindingModel model) {
try {
_logic.Create(model);
}
catch (Exception ex) {
_logger.LogError(ex, "Ошибка регистрации");
throw;
}
}
[HttpPost]
public void UpdateData(ClientBindingModel model) {
try {
_logic.Update(model);
}
catch (Exception ex) {
_logger.LogError(ex, "Ошибка обновления данных");
throw;
}
}
}
}

View File

@ -0,0 +1,58 @@
using ElectronicsShopContracts.BindingModels;
using ElectronicsShopContracts.BusinessLogicContracts;
using ElectronicsShopContracts.SearchModels;
using ElectronicsShopContracts.ViewModels;
using Microsoft.AspNetCore.Mvc;
namespace ElectronicsShopRestAPI.Controllers {
[Route("api/[controller]/[action]")]
[ApiController]
public class EmployeeController : Controller {
private readonly ILogger _logger;
private readonly IEmployeeLogic _logic;
public EmployeeController(ILogger<EmployeeController> logger, IEmployeeLogic logic) {
_logger = logger;
_logic = logic;
}
[HttpGet]
public EmployeeViewModel? Login(string login, string password) {
try {
return _logic.ReadElemet(new EmployeeSearchModel {
Login = login,
Password = password
});
}
catch (Exception ex) {
_logger.LogError(ex, "Ошибка входа в систему");
throw;
}
}
[HttpPost]
public void Register(EmployeeBindingModel model) {
try {
_logic.Create(model);
}
catch (Exception ex) {
_logger.LogError(ex, "Ошибка регистрации");
throw;
}
}
[HttpPost]
public void UpdateData(EmployeeBindingModel model) {
try {
_logic.Update(model);
}
catch (Exception ex) {
_logger.LogError(ex, "Ошибка обновления данных");
throw;
}
}
}
}

View File

@ -4,7 +4,7 @@
<TargetFramework>net8.0</TargetFramework> <TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
<InvariantGlobalization>true</InvariantGlobalization> <InvariantGlobalization>false</InvariantGlobalization>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
@ -12,7 +12,9 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\ElectronicsShopBusinessLogic\ElectronicsShopBusinessLogic.csproj" />
<ProjectReference Include="..\ElectronicsShopContracts\ElectronicsShopContracts.csproj" /> <ProjectReference Include="..\ElectronicsShopContracts\ElectronicsShopContracts.csproj" />
<ProjectReference Include="..\ElectronicsShopDataBaseImplement\ElectronicsShopDataBaseImplement.csproj" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@ -1,3 +1,7 @@
using ElectronicsShopBusinessLogic.BusinessLogic;
using ElectronicsShopContracts.BusinessLogicContracts;
using ElectronicsShopContracts.StorageContracts;
using ElectronicsShopDataBaseImplement.Implements;
using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Models;
var builder = WebApplication.CreateBuilder(args); var builder = WebApplication.CreateBuilder(args);
@ -6,6 +10,10 @@ var builder = WebApplication.CreateBuilder(args);
// Add services to the container. // Add services to the container.
builder.Services.AddTransient<IClientStorage, ClientStorage>();
builder.Services.AddTransient<IClientLogic, ClientLogic>();
builder.Services.AddControllers(); builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle // Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer(); builder.Services.AddEndpointsApiExplorer();

View File

@ -26,9 +26,6 @@
<th> <th>
Номер заказа Номер заказа
</th> </th>
<th>
Сотрудник
</th>
<th> <th>
Дата создания Дата создания
</th> </th>
@ -43,9 +40,6 @@
<th> <th>
@Html.DisplayFor(modelItem => item.ID) @Html.DisplayFor(modelItem => item.ID)
</th> </th>
<th>
@Html.DisplayFor(modelItem => item.EmployeeID)
</th>
<th> <th>
@Html.DisplayFor(modelItem => item.DateCreate) @Html.DisplayFor(modelItem => item.DateCreate)
</th> </th>