From bf68282103755a1299d87bc922d51f6667f0b376 Mon Sep 17 00:00:00 2001 From: ekallin Date: Sun, 7 Apr 2024 23:44:32 +0300 Subject: [PATCH] =?UTF-8?q?=D0=B2=D0=BE=D1=82=20=D0=A2=D0=95=D0=9F=D0=95?= =?UTF-8?q?=D0=A0=D0=AC=20=D0=B2=D1=80=D0=BE=D0=B4=D0=B5=20=D0=B2=D1=81?= =?UTF-8?q?=D0=B5...=20=D0=BC=D0=B5=D0=BD=D1=8F=20=D1=81=D1=8A=D0=B5=D0=B4?= =?UTF-8?q?=D1=8F=D1=82=20=D0=B7=D0=B0=20=D0=BA=D0=BE=D0=BB=D0=B8=D1=87?= =?UTF-8?q?=D0=B5=D1=81=D1=82=D0=B2=D0=BE=20=D0=B8=D0=B7=D0=BC=D0=B5=D0=BD?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B9=20=D0=B8=20=D0=BA=D0=BE=D0=BC=D0=BC?= =?UTF-8?q?=D0=B8=D1=82=D0=BE=D0=B2=20=D0=B1=D0=BB=D0=B8=D0=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SushiBar/SushiBarView.csproj | 2 +- .../SushiBarBusinessLogic.csproj | 2 +- .../Controllers/HomeController.cs | 7 ++-- SushiBarClientApp/Program.cs | 2 +- .../Properties/launchSettings.json | 34 +++++++++---------- SushiBarClientApp/SushiBarClientApp.csproj | 26 +++++++------- SushiBarClientApp/Views/Home/Create.cshtml | 10 ++++-- SushiBarContracts/SushiBarContracts.csproj | 2 +- SushiBarDataModels/SushiBarDataModels.csproj | 2 +- .../Implements/ClientStorage.cs | 27 +++++++++++---- .../SushiBarDatabaseImplement.csproj | 2 +- .../SushiBarFileImplement.csproj | 2 +- .../SushiBarListImplements.csproj | 2 +- SushiBarRestApi/SushiBarRestApi.csproj | 1 + 14 files changed, 73 insertions(+), 48 deletions(-) diff --git a/SushiBar/SushiBarView.csproj b/SushiBar/SushiBarView.csproj index 09adf49..145699a 100644 --- a/SushiBar/SushiBarView.csproj +++ b/SushiBar/SushiBarView.csproj @@ -9,7 +9,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/SushiBarBusinessLogic/SushiBarBusinessLogic.csproj b/SushiBarBusinessLogic/SushiBarBusinessLogic.csproj index a674e60..e4a0150 100644 --- a/SushiBarBusinessLogic/SushiBarBusinessLogic.csproj +++ b/SushiBarBusinessLogic/SushiBarBusinessLogic.csproj @@ -8,7 +8,7 @@ - + diff --git a/SushiBarClientApp/Controllers/HomeController.cs b/SushiBarClientApp/Controllers/HomeController.cs index c0079ca..07ba9b2 100644 --- a/SushiBarClientApp/Controllers/HomeController.cs +++ b/SushiBarClientApp/Controllers/HomeController.cs @@ -106,7 +106,7 @@ namespace SushiBarClientApp.Controllers [HttpGet] public IActionResult Create() { - ViewBag.Sushis = APIClient.GetRequest>("api/main/getsushislist"); + ViewBag.Sushis = APIClient.GetRequest>("api/main/getsushilist"); return View(); } [HttpPost] @@ -132,8 +132,9 @@ namespace SushiBarClientApp.Controllers [HttpPost] public double Calc(int count, int sushi) { - var sush = APIClient.GetRequest($"api/main/getsushi?sushiId={sushi}"); - return count * (sush?.Price ?? 1); + var prod = APIClient.GetRequest($"api/main/getsushi?sushiId={sushi}" + ); + return count * (prod?.Price ?? 1); } } } diff --git a/SushiBarClientApp/Program.cs b/SushiBarClientApp/Program.cs index 97baa34..8a8b56e 100644 --- a/SushiBarClientApp/Program.cs +++ b/SushiBarClientApp/Program.cs @@ -18,4 +18,4 @@ app.UseAuthorization(); app.MapControllerRoute( name: "default", pattern: "{controller=Home}/{action=Index}/{id?}"); -app.Run(); +app.Run(); \ No newline at end of file diff --git a/SushiBarClientApp/Properties/launchSettings.json b/SushiBarClientApp/Properties/launchSettings.json index 06caa43..372c338 100644 --- a/SushiBarClientApp/Properties/launchSettings.json +++ b/SushiBarClientApp/Properties/launchSettings.json @@ -1,31 +1,22 @@ -{ - "$schema": "http://json.schemastore.org/launchsettings.json", - "iisSettings": { - "windowsAuthentication": false, - "anonymousAuthentication": true, - "iisExpress": { - "applicationUrl": "http://localhost:41478", - "sslPort": 44302 - } - }, +{ "profiles": { "http": { "commandName": "Project", - "dotnetRunMessages": true, "launchBrowser": true, - "applicationUrl": "http://localhost:5222", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" - } + }, + "dotnetRunMessages": true, + "applicationUrl": "http://localhost:5222" }, "https": { "commandName": "Project", - "dotnetRunMessages": true, "launchBrowser": true, - "applicationUrl": "https://localhost:7084;http://localhost:5222", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" - } + }, + "dotnetRunMessages": true, + "applicationUrl": "https://localhost:7084;http://localhost:5222" }, "IIS Express": { "commandName": "IISExpress", @@ -34,5 +25,14 @@ "ASPNETCORE_ENVIRONMENT": "Development" } } + }, + "$schema": "http://json.schemastore.org/launchsettings.json", + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:41478", + "sslPort": 44302 + } } -} +} \ No newline at end of file diff --git a/SushiBarClientApp/SushiBarClientApp.csproj b/SushiBarClientApp/SushiBarClientApp.csproj index 79f4a53..b6bd040 100644 --- a/SushiBarClientApp/SushiBarClientApp.csproj +++ b/SushiBarClientApp/SushiBarClientApp.csproj @@ -1,19 +1,21 @@ - - net8.0 - enable - enable - + + net8.0 + enable + enable + - - - - - - - + + + + + + + + + diff --git a/SushiBarClientApp/Views/Home/Create.cshtml b/SushiBarClientApp/Views/Home/Create.cshtml index 5eade25..e2d2305 100644 --- a/SushiBarClientApp/Views/Home/Create.cshtml +++ b/SushiBarClientApp/Views/Home/Create.cshtml @@ -8,7 +8,12 @@
Суши:
- +
@@ -46,7 +51,8 @@ url: "/Home/Calc", data: { count: count, sushi: sushi }, success: function (result) { - $("#sum").val(result); + var roundedResult = parseFloat(result).toFixed(2); + $("#sum").val(roundedResult); } }); }; diff --git a/SushiBarContracts/SushiBarContracts.csproj b/SushiBarContracts/SushiBarContracts.csproj index e2168aa..2835487 100644 --- a/SushiBarContracts/SushiBarContracts.csproj +++ b/SushiBarContracts/SushiBarContracts.csproj @@ -7,7 +7,7 @@ - + diff --git a/SushiBarDataModels/SushiBarDataModels.csproj b/SushiBarDataModels/SushiBarDataModels.csproj index be62808..a67f13a 100644 --- a/SushiBarDataModels/SushiBarDataModels.csproj +++ b/SushiBarDataModels/SushiBarDataModels.csproj @@ -7,7 +7,7 @@ - + diff --git a/SushiBarDatabaseImplement/Implements/ClientStorage.cs b/SushiBarDatabaseImplement/Implements/ClientStorage.cs index 30be747..07359b3 100644 --- a/SushiBarDatabaseImplement/Implements/ClientStorage.cs +++ b/SushiBarDatabaseImplement/Implements/ClientStorage.cs @@ -1,4 +1,5 @@ -using SushiBarContracts.BindingModel; +using Microsoft.IdentityModel.Tokens; +using SushiBarContracts.BindingModel; using SushiBarContracts.SearchModel; using SushiBarContracts.StoragesContracts; using SushiBarContracts.ViewModels; @@ -45,16 +46,30 @@ namespace SushiBarDatabaseImplement.Implements public ClientViewModel? GetElement(ClientSearchModel model) { - if (string.IsNullOrEmpty(model.Email) && !model.Id.HasValue) { return null; } - using var context = new SushiBarDatabase(); - return context.Clients.FirstOrDefault(x => (!(string.IsNullOrEmpty(model.Email)) && model.Email == x.Email) || (model.Id.HasValue && model.Id == x.Id))?.GetViewModel; + return GetFilteredList(model).FirstOrDefault(); } public List GetFilteredList(ClientSearchModel model) { - if (string.IsNullOrEmpty(model.Email)) { return new(); } using var context = new SushiBarDatabase(); - return context.Clients.Where(x => x.Email.Contains(model.Email)).Select(x => x.GetViewModel).ToList(); + var clients = context.Clients.Select(x => x.GetViewModel).ToList(); + if (model.Id.HasValue) + { + clients = clients.Where(x => x.Id == model.Id.Value).ToList(); + } + if (!model.Email.IsNullOrEmpty()) + { + clients = clients.Where(x => x.Email == model.Email).ToList(); + } + if (!model.Password.IsNullOrEmpty()) + { + clients = clients.Where(x => x.Password == model.Password).ToList(); + } + if (!model.ClientFIO.IsNullOrEmpty()) + { + clients = clients.Where(x => x.ClientFIO == model.ClientFIO).ToList(); + } + return clients; } public List GetFullList() diff --git a/SushiBarDatabaseImplement/SushiBarDatabaseImplement.csproj b/SushiBarDatabaseImplement/SushiBarDatabaseImplement.csproj index 5df6334..e86f101 100644 --- a/SushiBarDatabaseImplement/SushiBarDatabaseImplement.csproj +++ b/SushiBarDatabaseImplement/SushiBarDatabaseImplement.csproj @@ -7,7 +7,7 @@ - + diff --git a/SushiBarFileImplement/SushiBarFileImplement.csproj b/SushiBarFileImplement/SushiBarFileImplement.csproj index 15b6044..f7a1d40 100644 --- a/SushiBarFileImplement/SushiBarFileImplement.csproj +++ b/SushiBarFileImplement/SushiBarFileImplement.csproj @@ -7,7 +7,7 @@ - + diff --git a/SushiBarListImplements/SushiBarListImplements.csproj b/SushiBarListImplements/SushiBarListImplements.csproj index 15b6044..f7a1d40 100644 --- a/SushiBarListImplements/SushiBarListImplements.csproj +++ b/SushiBarListImplements/SushiBarListImplements.csproj @@ -7,7 +7,7 @@ - + diff --git a/SushiBarRestApi/SushiBarRestApi.csproj b/SushiBarRestApi/SushiBarRestApi.csproj index 830945e..546a183 100644 --- a/SushiBarRestApi/SushiBarRestApi.csproj +++ b/SushiBarRestApi/SushiBarRestApi.csproj @@ -7,6 +7,7 @@ +