Готово

This commit is contained in:
Allllen4a 2024-04-07 19:43:03 +04:00
parent c664ac9f46
commit d9463e4f4c
17 changed files with 233 additions and 207 deletions

View File

@ -17,9 +17,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PizzeriaFileImplement", "Pi
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PizzeriaDatabaseImplement", "PizzeriaDatabaseImplement\PizzeriaDatabaseImplement.csproj", "{AA78A273-0E83-4B45-A155-F9CAFD64E895}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PizzeriaDatabaseImplement", "PizzeriaDatabaseImplement\PizzeriaDatabaseImplement.csproj", "{AA78A273-0E83-4B45-A155-F9CAFD64E895}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PizzeriaRestApi", "PizzeriaRestApi\PizzeriaRestApi.csproj", "{86BFFB1F-C08C-4939-91F3-7A582996065B}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PizzeriaRestApi", "PizzeriaRestApi\PizzeriaRestApi.csproj", "{6D8E3DBB-9AB7-4C2B-9F26-3FCBEE3362D8}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PizzeriaClientApp", "PizzeriaClientApp\PizzeriaClientApp.csproj", "{11B12B10-0ADF-4FBA-9DFC-5DF8E5ACD888}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PizzeriaClientApp", "PizzeriaClientApp\PizzeriaClientApp.csproj", "{8E483155-EC2D-460A-9B65-1B6831C5E441}"
EndProject EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -55,14 +55,14 @@ Global
{AA78A273-0E83-4B45-A155-F9CAFD64E895}.Debug|Any CPU.Build.0 = Debug|Any CPU {AA78A273-0E83-4B45-A155-F9CAFD64E895}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AA78A273-0E83-4B45-A155-F9CAFD64E895}.Release|Any CPU.ActiveCfg = Release|Any CPU {AA78A273-0E83-4B45-A155-F9CAFD64E895}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AA78A273-0E83-4B45-A155-F9CAFD64E895}.Release|Any CPU.Build.0 = Release|Any CPU {AA78A273-0E83-4B45-A155-F9CAFD64E895}.Release|Any CPU.Build.0 = Release|Any CPU
{86BFFB1F-C08C-4939-91F3-7A582996065B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {6D8E3DBB-9AB7-4C2B-9F26-3FCBEE3362D8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{86BFFB1F-C08C-4939-91F3-7A582996065B}.Debug|Any CPU.Build.0 = Debug|Any CPU {6D8E3DBB-9AB7-4C2B-9F26-3FCBEE3362D8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{86BFFB1F-C08C-4939-91F3-7A582996065B}.Release|Any CPU.ActiveCfg = Release|Any CPU {6D8E3DBB-9AB7-4C2B-9F26-3FCBEE3362D8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{86BFFB1F-C08C-4939-91F3-7A582996065B}.Release|Any CPU.Build.0 = Release|Any CPU {6D8E3DBB-9AB7-4C2B-9F26-3FCBEE3362D8}.Release|Any CPU.Build.0 = Release|Any CPU
{11B12B10-0ADF-4FBA-9DFC-5DF8E5ACD888}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {8E483155-EC2D-460A-9B65-1B6831C5E441}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{11B12B10-0ADF-4FBA-9DFC-5DF8E5ACD888}.Debug|Any CPU.Build.0 = Debug|Any CPU {8E483155-EC2D-460A-9B65-1B6831C5E441}.Debug|Any CPU.Build.0 = Debug|Any CPU
{11B12B10-0ADF-4FBA-9DFC-5DF8E5ACD888}.Release|Any CPU.ActiveCfg = Release|Any CPU {8E483155-EC2D-460A-9B65-1B6831C5E441}.Release|Any CPU.ActiveCfg = Release|Any CPU
{11B12B10-0ADF-4FBA-9DFC-5DF8E5ACD888}.Release|Any CPU.Build.0 = Release|Any CPU {8E483155-EC2D-460A-9B65-1B6831C5E441}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE

View File

@ -39,7 +39,7 @@ namespace PizzeriaClientApp.Controllers
{ {
if (APIClient.Client == null) if (APIClient.Client == null)
{ {
throw new Exception("Вы не авторизованы"); throw new Exception("Вы как суда попали? Суда вход только авторизованным");
} }
if (string.IsNullOrEmpty(login) || string.IsNullOrEmpty(password) || string.IsNullOrEmpty(fio)) if (string.IsNullOrEmpty(login) || string.IsNullOrEmpty(password) || string.IsNullOrEmpty(fio))
{ {
@ -121,7 +121,7 @@ namespace PizzeriaClientApp.Controllers
{ {
if (APIClient.Client == null) if (APIClient.Client == null)
{ {
throw new Exception("Вы не авторизованы"); throw new Exception("Вы как суда попали? Суда вход только авторизованным");
} }
if (count <= 0) if (count <= 0)
{ {

View File

@ -6,10 +6,6 @@
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup> </PropertyGroup>
<ItemGroup>
<Compile Include="..\PizzeriaContracts\ViewModels\OrderViewModel.cs" Link="OrderViewModel.cs" />
</ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" /> <PackageReference Include="Newtonsoft.Json" Version="13.0.2" />
</ItemGroup> </ItemGroup>

View File

@ -3,8 +3,8 @@
"windowsAuthentication": false, "windowsAuthentication": false,
"anonymousAuthentication": true, "anonymousAuthentication": true,
"iisExpress": { "iisExpress": {
"applicationUrl": "http://localhost:28755", "applicationUrl": "http://localhost:59663",
"sslPort": 44389 "sslPort": 44301
} }
}, },
"profiles": { "profiles": {
@ -12,7 +12,7 @@
"commandName": "Project", "commandName": "Project",
"dotnetRunMessages": true, "dotnetRunMessages": true,
"launchBrowser": true, "launchBrowser": true,
"applicationUrl": "https://localhost:7056;http://localhost:5138", "applicationUrl": "https://localhost:7132;http://localhost:5220",
"environmentVariables": { "environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development" "ASPNETCORE_ENVIRONMENT": "Development"
} }

View File

@ -6,5 +6,5 @@
} }
}, },
"AllowedHosts": "*", "AllowedHosts": "*",
"IPAddress": "http://localhost:5104/" "IPAddress": "http://localhost:5129/"
} }

View File

@ -1,68 +0,0 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace PizzeriaDatabaseImplement.Migrations
{
/// <inheritdoc />
public partial class InitClient : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<int>(
name: "ClientId",
table: "Orders",
type: "int",
nullable: false,
defaultValue: 0);
migrationBuilder.CreateTable(
name: "Clients",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
ClientFIO = table.Column<string>(type: "nvarchar(max)", nullable: false),
Email = table.Column<string>(type: "nvarchar(max)", nullable: false),
Password = table.Column<string>(type: "nvarchar(max)", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Clients", x => x.Id);
});
migrationBuilder.CreateIndex(
name: "IX_Orders_ClientId",
table: "Orders",
column: "ClientId");
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_Orders_Clients_ClientId",
table: "Orders");
migrationBuilder.DropTable(
name: "Clients");
migrationBuilder.DropIndex(
name: "IX_Orders_ClientId",
table: "Orders");
migrationBuilder.DropColumn(
name: "ClientId",
table: "Orders");
}
}
}

View File

@ -12,8 +12,8 @@ using PizzeriaDatabaseImplement;
namespace PizzeriaDatabaseImplement.Migrations namespace PizzeriaDatabaseImplement.Migrations
{ {
[DbContext(typeof(PizzeriaDatabase))] [DbContext(typeof(PizzeriaDatabase))]
[Migration("20240403141650_InitClient")] [Migration("20240407121638_InitMigration")]
partial class InitClient partial class InitMigration
{ {
/// <inheritdoc /> /// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder) protected override void BuildTargetModel(ModelBuilder modelBuilder)

View File

@ -5,10 +5,27 @@ using Microsoft.EntityFrameworkCore.Migrations;
namespace PizzeriaDatabaseImplement.Migrations namespace PizzeriaDatabaseImplement.Migrations
{ {
/// <inheritdoc />
public partial class InitMigration : Migration public partial class InitMigration : Migration
{ {
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder) protected override void Up(MigrationBuilder migrationBuilder)
{ {
migrationBuilder.CreateTable(
name: "Clients",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
ClientFIO = table.Column<string>(type: "nvarchar(max)", nullable: false),
Email = table.Column<string>(type: "nvarchar(max)", nullable: false),
Password = table.Column<string>(type: "nvarchar(max)", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Clients", x => x.Id);
});
migrationBuilder.CreateTable( migrationBuilder.CreateTable(
name: "Components", name: "Components",
columns: table => new columns: table => new
@ -43,6 +60,7 @@ namespace PizzeriaDatabaseImplement.Migrations
{ {
Id = table.Column<int>(type: "int", nullable: false) Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"), .Annotation("SqlServer:Identity", "1, 1"),
ClientId = table.Column<int>(type: "int", nullable: false),
PizzaId = table.Column<int>(type: "int", nullable: false), PizzaId = table.Column<int>(type: "int", nullable: false),
Count = table.Column<int>(type: "int", nullable: false), Count = table.Column<int>(type: "int", nullable: false),
Sum = table.Column<double>(type: "float", nullable: false), Sum = table.Column<double>(type: "float", nullable: false),
@ -53,6 +71,12 @@ namespace PizzeriaDatabaseImplement.Migrations
constraints: table => constraints: table =>
{ {
table.PrimaryKey("PK_Orders", x => x.Id); 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);
table.ForeignKey( table.ForeignKey(
name: "FK_Orders_Pizzas_PizzaId", name: "FK_Orders_Pizzas_PizzaId",
column: x => x.PizzaId, column: x => x.PizzaId,
@ -88,6 +112,11 @@ namespace PizzeriaDatabaseImplement.Migrations
onDelete: ReferentialAction.Cascade); onDelete: ReferentialAction.Cascade);
}); });
migrationBuilder.CreateIndex(
name: "IX_Orders_ClientId",
table: "Orders",
column: "ClientId");
migrationBuilder.CreateIndex( migrationBuilder.CreateIndex(
name: "IX_Orders_PizzaId", name: "IX_Orders_PizzaId",
table: "Orders", table: "Orders",
@ -104,6 +133,7 @@ namespace PizzeriaDatabaseImplement.Migrations
column: "PizzaId"); column: "PizzaId");
} }
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder) protected override void Down(MigrationBuilder migrationBuilder)
{ {
migrationBuilder.DropTable( migrationBuilder.DropTable(
@ -112,6 +142,9 @@ namespace PizzeriaDatabaseImplement.Migrations
migrationBuilder.DropTable( migrationBuilder.DropTable(
name: "PizzaComponents"); name: "PizzaComponents");
migrationBuilder.DropTable(
name: "Clients");
migrationBuilder.DropTable( migrationBuilder.DropTable(
name: "Components"); name: "Components");

View File

@ -12,17 +12,43 @@ using PizzeriaDatabaseImplement;
namespace PizzeriaDatabaseImplement.Migrations namespace PizzeriaDatabaseImplement.Migrations
{ {
[DbContext(typeof(PizzeriaDatabase))] [DbContext(typeof(PizzeriaDatabase))]
[Migration("20240309113549_InitMigration")] [Migration("20240407121716_ClientMigration")]
partial class InitMigration partial class ClientMigration
{ {
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder) protected override void BuildTargetModel(ModelBuilder modelBuilder)
{ {
#pragma warning disable 612, 618 #pragma warning disable 612, 618
modelBuilder modelBuilder
.HasAnnotation("ProductVersion", "6.0.27") .HasAnnotation("ProductVersion", "7.0.3")
.HasAnnotation("Relational:MaxIdentifierLength", 128); .HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1); SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("PizzeriaDatabaseImplement.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("PizzeriaDatabaseImplement.Models.Component", b => modelBuilder.Entity("PizzeriaDatabaseImplement.Models.Component", b =>
{ {
@ -30,7 +56,7 @@ namespace PizzeriaDatabaseImplement.Migrations
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("int"); .HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"), 1L, 1); SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("ComponentName") b.Property<string>("ComponentName")
.IsRequired() .IsRequired()
@ -50,7 +76,10 @@ namespace PizzeriaDatabaseImplement.Migrations
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("int"); .HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"), 1L, 1); SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("ClientId")
.HasColumnType("int");
b.Property<int>("Count") b.Property<int>("Count")
.HasColumnType("int"); .HasColumnType("int");
@ -72,6 +101,8 @@ namespace PizzeriaDatabaseImplement.Migrations
b.HasKey("Id"); b.HasKey("Id");
b.HasIndex("ClientId");
b.HasIndex("PizzaId"); b.HasIndex("PizzaId");
b.ToTable("Orders"); b.ToTable("Orders");
@ -83,7 +114,7 @@ namespace PizzeriaDatabaseImplement.Migrations
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("int"); .HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"), 1L, 1); SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("PizzaName") b.Property<string>("PizzaName")
.IsRequired() .IsRequired()
@ -103,7 +134,7 @@ namespace PizzeriaDatabaseImplement.Migrations
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("int"); .HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"), 1L, 1); SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("ComponentId") b.Property<int>("ComponentId")
.HasColumnType("int"); .HasColumnType("int");
@ -125,12 +156,20 @@ namespace PizzeriaDatabaseImplement.Migrations
modelBuilder.Entity("PizzeriaDatabaseImplement.Models.Order", b => modelBuilder.Entity("PizzeriaDatabaseImplement.Models.Order", b =>
{ {
b.HasOne("PizzeriaDatabaseImplement.Models.Client", "Client")
.WithMany("Orders")
.HasForeignKey("ClientId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("PizzeriaDatabaseImplement.Models.Pizza", "Pizza") b.HasOne("PizzeriaDatabaseImplement.Models.Pizza", "Pizza")
.WithMany("Orders") .WithMany("Orders")
.HasForeignKey("PizzaId") .HasForeignKey("PizzaId")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.IsRequired(); .IsRequired();
b.Navigation("Client");
b.Navigation("Pizza"); b.Navigation("Pizza");
}); });
@ -153,6 +192,11 @@ namespace PizzeriaDatabaseImplement.Migrations
b.Navigation("Pizza"); b.Navigation("Pizza");
}); });
modelBuilder.Entity("PizzeriaDatabaseImplement.Models.Client", b =>
{
b.Navigation("Orders");
});
modelBuilder.Entity("PizzeriaDatabaseImplement.Models.Component", b => modelBuilder.Entity("PizzeriaDatabaseImplement.Models.Component", b =>
{ {
b.Navigation("PizzaComponents"); b.Navigation("PizzaComponents");

View File

@ -0,0 +1,22 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace PizzeriaDatabaseImplement.Migrations
{
/// <inheritdoc />
public partial class ClientMigration : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
}
}
}

View File

@ -4,8 +4,8 @@
"windowsAuthentication": false, "windowsAuthentication": false,
"anonymousAuthentication": true, "anonymousAuthentication": true,
"iisExpress": { "iisExpress": {
"applicationUrl": "http://localhost:47639", "applicationUrl": "http://localhost:10859",
"sslPort": 44347 "sslPort": 44324
} }
}, },
"profiles": { "profiles": {
@ -14,7 +14,7 @@
"dotnetRunMessages": true, "dotnetRunMessages": true,
"launchBrowser": true, "launchBrowser": true,
"launchUrl": "swagger", "launchUrl": "swagger",
"applicationUrl": "https://localhost:7075;http://localhost:5104", "applicationUrl": "https://localhost:7043;http://localhost:5129",
"environmentVariables": { "environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development" "ASPNETCORE_ENVIRONMENT": "Development"
} }

View File

@ -1,5 +1,4 @@
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Pizzeria;
using PizzeriaContracts.BindingModels; using PizzeriaContracts.BindingModels;
using PizzeriaContracts.BusinessLogicsContracts; using PizzeriaContracts.BusinessLogicsContracts;