ITS DROPPED

This commit is contained in:
Sergey Kozyrev 2024-04-03 22:24:36 +04:00
parent 06e5c74429
commit e8749062be
11 changed files with 146 additions and 33 deletions

View File

@ -10,7 +10,7 @@ namespace SewingDressesClientApp
public static ClientViewModel? Client { get; set; } = null; public static ClientViewModel? Client { get; set; } = null;
public static void Connect(IConfiguration configuration) public static void Connect(IConfiguration configuration)
{ {
_client.BaseAddress = new Uri(configuration["IPAddress"]); _client.BaseAddress = new Uri(configuration["IPAddress"]!);
_client.DefaultRequestHeaders.Accept.Clear(); _client.DefaultRequestHeaders.Accept.Clear();
_client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); _client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
} }

View File

@ -3,9 +3,8 @@ using SewingDressesContracts.ViewModels;
using SewingDressesClientApp.Models; using SewingDressesClientApp.Models;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using System.Diagnostics; using System.Diagnostics;
using SewingDressesClientApp;
namespace AbstractShowClientApp.Controllers namespace SewingDressesClientApp.Controllers
{ {
public class HomeController : Controller public class HomeController : Controller
{ {
@ -18,7 +17,7 @@ namespace AbstractShowClientApp.Controllers
{ {
if (APIClient.Client == null) if (APIClient.Client == null)
{ {
return Redirect("~/Home/Enter"); return View("Enter");
} }
return return
View(APIClient.GetRequest<List<OrderViewModel>>($"api/main/getorders?clientId={APIClient.Client.Id}")); View(APIClient.GetRequest<List<OrderViewModel>>($"api/main/getorders?clientId={APIClient.Client.Id}"));
@ -28,7 +27,7 @@ namespace AbstractShowClientApp.Controllers
{ {
if (APIClient.Client == null) if (APIClient.Client == null)
{ {
return Redirect("~/Home/Enter"); return View("Enter");
} }
return View(APIClient.Client); return View(APIClient.Client);
} }
@ -57,8 +56,7 @@ namespace AbstractShowClientApp.Controllers
APIClient.Client.Password = password; APIClient.Client.Password = password;
Response.Redirect("Index"); Response.Redirect("Index");
} }
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
NoStore = true)]
public IActionResult Error() public IActionResult Error()
{ {
return View(new ErrorViewModel return View(new ErrorViewModel

View File

@ -1,20 +1,28 @@
using AbstractShowClientApp;
using SewingDressesClientApp; using SewingDressesClientApp;
var builder = WebApplication.CreateBuilder(args); var builder = WebApplication.CreateBuilder(args);
builder.Services.AddControllersWithViews();
builder.Services.AddControllersWithViews().AddRazorRuntimeCompilation();
var app = builder.Build(); var app = builder.Build();
APIClient.Connect(builder.Configuration); APIClient.Connect(builder.Configuration);
if (!app.Environment.IsDevelopment()) if (!app.Environment.IsDevelopment())
{ {
app.UseExceptionHandler("/Home/Error"); app.UseExceptionHandler("/Home/Error");
app.UseHsts(); app.UseHsts();
} }
app.UseHttpsRedirection(); app.UseHttpsRedirection();
app.UseStaticFiles(); app.UseStaticFiles();
app.UseRouting(); app.UseRouting();
app.UseAuthorization(); app.UseAuthorization();
app.MapControllerRoute( app.MapControllerRoute(
name: "default", name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}"); pattern: "{controller=Home}/{action=Index}/{id?}");
app.Run(); app.Run();

View File

@ -7,20 +7,12 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="6.0.26" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" /> <PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\SewingDressesBusinessLogic\SewingDressesBusinessLogic.csproj" />
<ProjectReference Include="..\SewingDressesContracts\SewingDressesContracts.csproj" /> <ProjectReference Include="..\SewingDressesContracts\SewingDressesContracts.csproj" />
<ProjectReference Include="..\SewingDressesDatabaseImplement\SewingDressesDatabaseImplement.csproj" /> </ItemGroup>
<ProjectReference Include="..\SewingDressesDataModels\SewingDressesDataModels.csproj" />
</ItemGroup>
<ItemGroup>
<Content Update="Views\Home\Enter.cshtml">
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
</Content>
</ItemGroup>
</Project> </Project>

View File

@ -6,7 +6,7 @@
</div> </div>
<form method="post"> <form method="post">
<div class="row"> <div class="row">
<div class="col-4">Изделие:</div> <div class="col-4">Платье:</div>
<div class="col-8"> <div class="col-8">
<select id="dress" name="dress" class="form-control" asp-items="@(new SelectList(@ViewBag.Dresses,"Id", "DressName"))"></select> <select id="dress" name="dress" class="form-control" asp-items="@(new SelectList(@ViewBag.Dresses,"Id", "DressName"))"></select>
</div> </div>

View File

@ -3,10 +3,10 @@
<head> <head>
<meta charset="utf-8" /> <meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>@ViewData["Title"] - AbstractShowClientApp</title> <title>@ViewData["Title"] - SewingDressesClientApp</title>
<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css" /> <link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css" />
<link rel="stylesheet" href="~/css/site.css" asp-append-version="true" /> <link rel="stylesheet" href="~/css/site.css" asp-append-version="true" />
<link rel="stylesheet" href="~/AbstractShowClientApp.styles.css" asp-append-version="true" /> <link rel="stylesheet" href="~/SewingDressesClientApp.styles.css" asp-append-version="true" />
</head> </head>
<body> <body>
<header> <header>
@ -44,7 +44,7 @@
<footer class="border-top footer text-muted"> <footer class="border-top footer text-muted">
<div class="container"> <div class="container">
&copy; 2023 - AbstractShowClientApp - <a asp-area="" asp-controller="Home" asp-action="Privacy">Privacy</a> &copy; 2023 - SewingDressesClientApp - <a asp-area="" asp-controller="Home" asp-action="Privacy">Privacy</a>
</div> </div>
</footer> </footer>
<script src="~/lib/jquery/dist/jquery.min.js"></script> <script src="~/lib/jquery/dist/jquery.min.js"></script>

View File

@ -6,6 +6,5 @@
} }
}, },
"AllowedHosts": "*", "AllowedHosts": "*",
"IPAddress": "http://localhost:7225/"
"IPAddress" : "http://localhost:5159/"
} }

View File

@ -9,10 +9,10 @@ using SewingDressesDatabaseImplement;
#nullable disable #nullable disable
namespace SewingDressesDatabaseImplement1.Migrations namespace SewingDressesDatabaseImplement.Migrations
{ {
[DbContext(typeof(SewingDressesDatabase))] [DbContext(typeof(SewingDressesDatabase))]
[Migration("20240308104531_InitialCreate")] [Migration("20240403180823_InitialCreate")]
partial class InitialCreate partial class InitialCreate
{ {
/// <inheritdoc /> /// <inheritdoc />
@ -20,11 +20,36 @@ namespace SewingDressesDatabaseImplement1.Migrations
{ {
#pragma warning disable 612, 618 #pragma warning disable 612, 618
modelBuilder modelBuilder
.HasAnnotation("ProductVersion", "8.0.2") .HasAnnotation("ProductVersion", "7.0.16")
.HasAnnotation("Relational:MaxIdentifierLength", 128); .HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("SewingDressesDatabaseImplement.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("SewingDressesDatabaseImplement.Models.Component", b => modelBuilder.Entity("SewingDressesDatabaseImplement.Models.Component", b =>
{ {
b.Property<int>("Id") b.Property<int>("Id")
@ -99,6 +124,9 @@ namespace SewingDressesDatabaseImplement1.Migrations
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id")); SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("ClientId")
.HasColumnType("int");
b.Property<int>("Count") b.Property<int>("Count")
.HasColumnType("int"); .HasColumnType("int");
@ -119,6 +147,8 @@ namespace SewingDressesDatabaseImplement1.Migrations
b.HasKey("Id"); b.HasKey("Id");
b.HasIndex("ClientId");
b.HasIndex("DressId"); b.HasIndex("DressId");
b.ToTable("Orders"); b.ToTable("Orders");
@ -145,6 +175,12 @@ namespace SewingDressesDatabaseImplement1.Migrations
modelBuilder.Entity("SewingDressesDatabaseImplement.Models.Order", b => modelBuilder.Entity("SewingDressesDatabaseImplement.Models.Order", b =>
{ {
b.HasOne("SewingDressesDatabaseImplement.Models.Client", null)
.WithMany("Orders")
.HasForeignKey("ClientId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("SewingDressesDatabaseImplement.Models.Dress", null) b.HasOne("SewingDressesDatabaseImplement.Models.Dress", null)
.WithMany("Orders") .WithMany("Orders")
.HasForeignKey("DressId") .HasForeignKey("DressId")
@ -152,6 +188,11 @@ namespace SewingDressesDatabaseImplement1.Migrations
.IsRequired(); .IsRequired();
}); });
modelBuilder.Entity("SewingDressesDatabaseImplement.Models.Client", b =>
{
b.Navigation("Orders");
});
modelBuilder.Entity("SewingDressesDatabaseImplement.Models.Component", b => modelBuilder.Entity("SewingDressesDatabaseImplement.Models.Component", b =>
{ {
b.Navigation("DressComponents"); b.Navigation("DressComponents");

View File

@ -3,7 +3,7 @@ using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable #nullable disable
namespace SewingDressesDatabaseImplement1.Migrations namespace SewingDressesDatabaseImplement.Migrations
{ {
/// <inheritdoc /> /// <inheritdoc />
public partial class InitialCreate : Migration public partial class InitialCreate : Migration
@ -11,6 +11,21 @@ namespace SewingDressesDatabaseImplement1.Migrations
/// <inheritdoc /> /// <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
@ -73,6 +88,7 @@ namespace SewingDressesDatabaseImplement1.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"),
DressId = table.Column<int>(type: "int", nullable: false), DressId = table.Column<int>(type: "int", nullable: false),
ClientId = 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),
Status = table.Column<int>(type: "int", nullable: false), Status = table.Column<int>(type: "int", nullable: false),
@ -82,6 +98,12 @@ namespace SewingDressesDatabaseImplement1.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_Dresses_DressId", name: "FK_Orders_Dresses_DressId",
column: x => x.DressId, column: x => x.DressId,
@ -100,6 +122,11 @@ namespace SewingDressesDatabaseImplement1.Migrations
table: "DressComponents", table: "DressComponents",
column: "DressId"); column: "DressId");
migrationBuilder.CreateIndex(
name: "IX_Orders_ClientId",
table: "Orders",
column: "ClientId");
migrationBuilder.CreateIndex( migrationBuilder.CreateIndex(
name: "IX_Orders_DressId", name: "IX_Orders_DressId",
table: "Orders", table: "Orders",
@ -118,6 +145,9 @@ namespace SewingDressesDatabaseImplement1.Migrations
migrationBuilder.DropTable( migrationBuilder.DropTable(
name: "Components"); name: "Components");
migrationBuilder.DropTable(
name: "Clients");
migrationBuilder.DropTable( migrationBuilder.DropTable(
name: "Dresses"); name: "Dresses");
} }

View File

@ -8,7 +8,7 @@ using SewingDressesDatabaseImplement;
#nullable disable #nullable disable
namespace SewingDressesDatabaseImplement1.Migrations namespace SewingDressesDatabaseImplement.Migrations
{ {
[DbContext(typeof(SewingDressesDatabase))] [DbContext(typeof(SewingDressesDatabase))]
partial class SewingDressesDatabaseModelSnapshot : ModelSnapshot partial class SewingDressesDatabaseModelSnapshot : ModelSnapshot
@ -17,11 +17,36 @@ namespace SewingDressesDatabaseImplement1.Migrations
{ {
#pragma warning disable 612, 618 #pragma warning disable 612, 618
modelBuilder modelBuilder
.HasAnnotation("ProductVersion", "8.0.2") .HasAnnotation("ProductVersion", "7.0.16")
.HasAnnotation("Relational:MaxIdentifierLength", 128); .HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("SewingDressesDatabaseImplement.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("SewingDressesDatabaseImplement.Models.Component", b => modelBuilder.Entity("SewingDressesDatabaseImplement.Models.Component", b =>
{ {
b.Property<int>("Id") b.Property<int>("Id")
@ -96,6 +121,9 @@ namespace SewingDressesDatabaseImplement1.Migrations
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id")); SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("ClientId")
.HasColumnType("int");
b.Property<int>("Count") b.Property<int>("Count")
.HasColumnType("int"); .HasColumnType("int");
@ -116,6 +144,8 @@ namespace SewingDressesDatabaseImplement1.Migrations
b.HasKey("Id"); b.HasKey("Id");
b.HasIndex("ClientId");
b.HasIndex("DressId"); b.HasIndex("DressId");
b.ToTable("Orders"); b.ToTable("Orders");
@ -142,6 +172,12 @@ namespace SewingDressesDatabaseImplement1.Migrations
modelBuilder.Entity("SewingDressesDatabaseImplement.Models.Order", b => modelBuilder.Entity("SewingDressesDatabaseImplement.Models.Order", b =>
{ {
b.HasOne("SewingDressesDatabaseImplement.Models.Client", null)
.WithMany("Orders")
.HasForeignKey("ClientId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("SewingDressesDatabaseImplement.Models.Dress", null) b.HasOne("SewingDressesDatabaseImplement.Models.Dress", null)
.WithMany("Orders") .WithMany("Orders")
.HasForeignKey("DressId") .HasForeignKey("DressId")
@ -149,6 +185,11 @@ namespace SewingDressesDatabaseImplement1.Migrations
.IsRequired(); .IsRequired();
}); });
modelBuilder.Entity("SewingDressesDatabaseImplement.Models.Client", b =>
{
b.Navigation("Orders");
});
modelBuilder.Entity("SewingDressesDatabaseImplement.Models.Component", b => modelBuilder.Entity("SewingDressesDatabaseImplement.Models.Component", b =>
{ {
b.Navigation("DressComponents"); b.Navigation("DressComponents");

View File

@ -20,4 +20,8 @@
<ProjectReference Include="..\SewingDressesDataModels\SewingDressesDataModels.csproj" /> <ProjectReference Include="..\SewingDressesDataModels\SewingDressesDataModels.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<Folder Include="Migrations\" />
</ItemGroup>
</Project> </Project>