From d025f0b025c6d9d96a3b7f0605ad604c1c162c41 Mon Sep 17 00:00:00 2001 From: goldfest Date: Thu, 18 Apr 2024 21:08:02 +0400 Subject: [PATCH] =?UTF-8?q?=D0=B4=D0=BE=D0=B4=D0=B5=D0=BB=D0=B0=D0=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- TravelCompany/TravelCompany.sln | 20 +- .../TravelCompanyClientApp/ApiClient.cs | 4 +- .../Controllers/HomeController.cs | 289 +++++++++--------- .../TravelCompanyClientApp/Program.cs | 3 +- .../Properties/launchSettings.json | 9 +- .../TravelCompanyClientApp.csproj | 2 - .../Views/Home/Create.cshtml | 19 +- .../Views/Home/Enter.cshtml | 3 +- .../Views/Home/Index.cshtml | 28 +- .../Views/Home/Privacy.cshtml | 6 +- .../Views/Home/Register.cshtml | 7 +- .../Views/Shared/_Layout.cshtml | 96 +++--- .../TravelCompanyClientApp/appsettings.json | 2 +- .../ViewModels/OrderViewModel.cs | 2 +- .../Implements/ClientStorage.cs | 5 + .../Models/Order.cs | 8 - .../Properties/launchSettings.json | 6 +- .../TravelCompanyRestApi.csproj | 2 +- .../TravelCompanyRestApi/log4net.config | 4 +- 19 files changed, 251 insertions(+), 264 deletions(-) diff --git a/TravelCompany/TravelCompany.sln b/TravelCompany/TravelCompany.sln index 30ca76c..d976e68 100644 --- a/TravelCompany/TravelCompany.sln +++ b/TravelCompany/TravelCompany.sln @@ -17,9 +17,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TravelCompanyFileImplement" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TravelCompanyDatabaseImplement", "TravelCompanyDatabaseImplement\TravelCompanyDatabaseImplement.csproj", "{1232CA3D-F5FE-4BD6-88E9-719F822E605B}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TravelCompanyRestApi", "TravelCompanyRestApi\TravelCompanyRestApi.csproj", "{EDF8977C-50AE-4011-8771-A39F7442331D}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TravelCompanyClientApp", "TravelCompanyClientApp\TravelCompanyClientApp.csproj", "{F1E802C4-EE5D-4508-B42F-3ACB70621013}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TravelCompanyClientApp", "TravelCompanyClientApp\TravelCompanyClientApp.csproj", "{8F25F567-8D4C-4178-A5A2-33D54A97417C}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TravelCompanyRestApi", "TravelCompanyRestApi\TravelCompanyRestApi.csproj", "{E24D011F-7289-4DBA-9C90-D49713C4E495}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -55,14 +55,14 @@ Global {1232CA3D-F5FE-4BD6-88E9-719F822E605B}.Debug|Any CPU.Build.0 = Debug|Any CPU {1232CA3D-F5FE-4BD6-88E9-719F822E605B}.Release|Any CPU.ActiveCfg = Release|Any CPU {1232CA3D-F5FE-4BD6-88E9-719F822E605B}.Release|Any CPU.Build.0 = Release|Any CPU - {EDF8977C-50AE-4011-8771-A39F7442331D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {EDF8977C-50AE-4011-8771-A39F7442331D}.Debug|Any CPU.Build.0 = Debug|Any CPU - {EDF8977C-50AE-4011-8771-A39F7442331D}.Release|Any CPU.ActiveCfg = Release|Any CPU - {EDF8977C-50AE-4011-8771-A39F7442331D}.Release|Any CPU.Build.0 = Release|Any CPU - {8F25F567-8D4C-4178-A5A2-33D54A97417C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {8F25F567-8D4C-4178-A5A2-33D54A97417C}.Debug|Any CPU.Build.0 = Debug|Any CPU - {8F25F567-8D4C-4178-A5A2-33D54A97417C}.Release|Any CPU.ActiveCfg = Release|Any CPU - {8F25F567-8D4C-4178-A5A2-33D54A97417C}.Release|Any CPU.Build.0 = Release|Any CPU + {F1E802C4-EE5D-4508-B42F-3ACB70621013}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F1E802C4-EE5D-4508-B42F-3ACB70621013}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F1E802C4-EE5D-4508-B42F-3ACB70621013}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F1E802C4-EE5D-4508-B42F-3ACB70621013}.Release|Any CPU.Build.0 = Release|Any CPU + {E24D011F-7289-4DBA-9C90-D49713C4E495}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E24D011F-7289-4DBA-9C90-D49713C4E495}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E24D011F-7289-4DBA-9C90-D49713C4E495}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E24D011F-7289-4DBA-9C90-D49713C4E495}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/TravelCompany/TravelCompanyClientApp/ApiClient.cs b/TravelCompany/TravelCompanyClientApp/ApiClient.cs index 4a6a9e8..96151c5 100644 --- a/TravelCompany/TravelCompanyClientApp/ApiClient.cs +++ b/TravelCompany/TravelCompanyClientApp/ApiClient.cs @@ -1,7 +1,7 @@ -using TravelCompanyContracts.ViewModels; -using System.Net.Http.Headers; +using System.Net.Http.Headers; using System.Text; using Newtonsoft.Json; +using TravelCompanyContracts.ViewModels; namespace TravelCompanyClientApp diff --git a/TravelCompany/TravelCompanyClientApp/Controllers/HomeController.cs b/TravelCompany/TravelCompanyClientApp/Controllers/HomeController.cs index bc95763..2432ef1 100644 --- a/TravelCompany/TravelCompanyClientApp/Controllers/HomeController.cs +++ b/TravelCompany/TravelCompanyClientApp/Controllers/HomeController.cs @@ -1,150 +1,151 @@ -using TravelCompanyClientApp.Models; +using Microsoft.AspNetCore.Mvc; +using System.Diagnostics; +using TravelCompanyClientApp.Models; +using TravelCompanyClientApp; using TravelCompanyContracts.BindingModels; using TravelCompanyContracts.ViewModels; -using Microsoft.AspNetCore.Mvc; -using System.Diagnostics; namespace TravelCompanyClientApp.Controllers { - public class HomeController : Controller - { - private readonly ILogger _logger; - public HomeController(ILogger logger) - { - _logger = logger; - } - public IActionResult Index() - { - if (APIClient.Client == null) - { - return Redirect("~/Home/Enter"); - } - return - View(APIClient.GetRequest>($"api/main/getorders?clientId={APIClient.Client.Id}")); - } - [HttpGet] - public IActionResult Privacy() - { - if (APIClient.Client == null) - { - return Redirect("~/Home/Enter"); - } - return View(APIClient.Client); - } - [HttpPost] - public void Privacy(string login, string password, string fio) - { - if (APIClient.Client == null) - { - throw new Exception("Вы как суда попали? Суда вход только авторизованным"); - } - if (string.IsNullOrEmpty(login) || - string.IsNullOrEmpty(password) || string.IsNullOrEmpty(fio)) - { - throw new Exception("Введите логин, пароль и ФИО"); - } - APIClient.PostRequest("api/client/updatedata", new - ClientBindingModel - { - Id = APIClient.Client.Id, - ClientFIO = fio, - Email = login, - Password = password - }); - APIClient.Client.ClientFIO = fio; - APIClient.Client.Email = login; - APIClient.Client.Password = password; - Response.Redirect("Index"); - } - [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, - NoStore = true)] - public IActionResult Error() - { - return View(new ErrorViewModel - { - RequestId = - Activity.Current?.Id ?? HttpContext.TraceIdentifier - }); - } - [HttpGet] - public IActionResult Enter() - { - return View(); - } - [HttpPost] - public void Enter(string login, string password) - { - if (string.IsNullOrEmpty(login) || - string.IsNullOrEmpty(password)) - { - throw new Exception("Введите логин и пароль"); - } - APIClient.Client = - APIClient.GetRequest($"api/client/login?login={login}&password={password}"); - if (APIClient.Client == null) - { - throw new Exception("Неверный логин/пароль"); - } - Response.Redirect("Index"); - } - [HttpGet] - public IActionResult Register() - { - return View(); - } - [HttpPost] - public void Register(string login, string password, string fio) - { - if (string.IsNullOrEmpty(login) || - string.IsNullOrEmpty(password) || string.IsNullOrEmpty(fio)) - { - throw new Exception("Введите логин, пароль и ФИО"); - } - APIClient.PostRequest("api/client/register", new - ClientBindingModel - { - ClientFIO = fio, - Email = login, - Password = password - }); - Response.Redirect("Enter"); - return; - } - [HttpGet] - public IActionResult Create() - { - ViewBag.Travels = - APIClient.GetRequest>("api/main/getTravellist"); - return View(); - } - [HttpPost] - public void Create(int Travel, int count) - { - if (APIClient.Client == null) - { - throw new Exception("Вы как суда попали? Суда вход только авторизованным"); - } - if (count <= 0) - { - throw new Exception("Количество и сумма должны быть больше 0"); - } - APIClient.PostRequest("api/main/createorder", new - OrderBindingModel - { - ClientId = APIClient.Client.Id, - TravelId = Travel, - Count = count, - Sum = Calc(count, Travel) - }); - Response.Redirect("Index"); - } - [HttpPost] - public double Calc(int count, int Travel) - { - var _Travel = - APIClient.GetRequest($"api/main/getTravel?Travelid={Travel}" - ); - return Math.Round(count * (_Travel?.Price ?? 1), 2); - } - } + public class HomeController : Controller + { + private readonly ILogger _logger; + public HomeController(ILogger logger) + { + _logger = logger; + } + public IActionResult Index() + { + if (APIClient.Client == null) + { + return Redirect("~/Home/Enter"); + } + return + View(APIClient.GetRequest>($"api/main/getorders?clientId={APIClient.Client.Id}")); + } + [HttpGet] + public IActionResult Privacy() + { + if (APIClient.Client == null) + { + return Redirect("~/Home/Enter"); + } + return View(APIClient.Client); + } + [HttpPost] + public void Privacy(string login, string password, string fio) + { + if (APIClient.Client == null) + { + throw new Exception("Вы как суда попали? Суда вход только авторизованным"); + } + if (string.IsNullOrEmpty(login) || + string.IsNullOrEmpty(password) || string.IsNullOrEmpty(fio)) + { + throw new Exception("Введите логин, пароль и ФИО"); + } + APIClient.PostRequest("api/client/updatedata", new + ClientBindingModel + { + Id = APIClient.Client.Id, + ClientFIO = fio, + Email = login, + Password = password + }); + APIClient.Client.ClientFIO = fio; + APIClient.Client.Email = login; + APIClient.Client.Password = password; + Response.Redirect("Index"); + } + [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, + NoStore = true)] + public IActionResult Error() + { + return View(new ErrorViewModel + { + RequestId = + Activity.Current?.Id ?? HttpContext.TraceIdentifier + }); + } + [HttpGet] + public IActionResult Enter() + { + return View(); + } + [HttpPost] + public void Enter(string login, string password) + { + if (string.IsNullOrEmpty(login) || + string.IsNullOrEmpty(password)) + { + throw new Exception("Введите логин и пароль"); + } + APIClient.Client = + APIClient.GetRequest($"api/client/login?login={login}&password={password}"); + if (APIClient.Client == null) + { + throw new Exception("Неверный логин/пароль"); + } + Response.Redirect("Index"); + } + [HttpGet] + public IActionResult Register() + { + return View(); + } + [HttpPost] + public void Register(string login, string password, string fio) + { + if (string.IsNullOrEmpty(login) || + string.IsNullOrEmpty(password) || string.IsNullOrEmpty(fio)) + { + throw new Exception("Введите логин, пароль и ФИО"); + } + APIClient.PostRequest("api/client/register", new + ClientBindingModel + { + ClientFIO = fio, + Email = login, + Password = password + }); + Response.Redirect("Enter"); + return; + } + [HttpGet] + public IActionResult Create() + { + ViewBag.Travels = + APIClient.GetRequest>("api/main/getTravellist"); + return View(); + } + [HttpPost] + public void Create(int Travel, int count) + { + if (APIClient.Client == null) + { + throw new Exception("Вы как суда попали? Суда вход только авторизованным"); + } + if (count <= 0) + { + throw new Exception("Количество и сумма должны быть больше 0"); + } + APIClient.PostRequest("api/main/createorder", new + OrderBindingModel + { + ClientId = APIClient.Client.Id, + TravelId = Travel, + Count = count, + Sum = Calc(count, Travel) + }); + Response.Redirect("Index"); + } + [HttpPost] + public double Calc(int count, int Travel) + { + var _Travel = + APIClient.GetRequest($"api/main/getTravel?Travelid={Travel}" + ); + return Math.Round(count * (_Travel?.Price ?? 1), 2); + } + } } diff --git a/TravelCompany/TravelCompanyClientApp/Program.cs b/TravelCompany/TravelCompanyClientApp/Program.cs index 1f6bd3c..68abc99 100644 --- a/TravelCompany/TravelCompanyClientApp/Program.cs +++ b/TravelCompany/TravelCompanyClientApp/Program.cs @@ -18,6 +18,7 @@ if (!app.Environment.IsDevelopment()) } app.UseHttpsRedirection(); + app.UseStaticFiles(); app.UseRouting(); @@ -28,4 +29,4 @@ app.MapControllerRoute( name: "default", pattern: "{controller=Home}/{action=Index}/{id?}"); -app.Run(); +app.Run(); \ No newline at end of file diff --git a/TravelCompany/TravelCompanyClientApp/Properties/launchSettings.json b/TravelCompany/TravelCompanyClientApp/Properties/launchSettings.json index 0cd2caa..22a4174 100644 --- a/TravelCompany/TravelCompanyClientApp/Properties/launchSettings.json +++ b/TravelCompany/TravelCompanyClientApp/Properties/launchSettings.json @@ -1,11 +1,10 @@ { - "$schema": "https://json.schemastore.org/launchsettings.json", "iisSettings": { "windowsAuthentication": false, "anonymousAuthentication": true, "iisExpress": { - "applicationUrl": "http://localhost:6592", - "sslPort": 44336 + "applicationUrl": "http://localhost:8145", + "sslPort": 44343 } }, "profiles": { @@ -13,8 +12,7 @@ "commandName": "Project", "dotnetRunMessages": true, "launchBrowser": true, - "launchUrl": "swagger", - "applicationUrl": "https://localhost:7237;http://localhost:5059", + "applicationUrl": "https://localhost:7019;http://localhost:5041", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" } @@ -22,7 +20,6 @@ "IIS Express": { "commandName": "IISExpress", "launchBrowser": true, - "launchUrl": "swagger", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" } diff --git a/TravelCompany/TravelCompanyClientApp/TravelCompanyClientApp.csproj b/TravelCompany/TravelCompanyClientApp/TravelCompanyClientApp.csproj index f174678..a3890cd 100644 --- a/TravelCompany/TravelCompanyClientApp/TravelCompanyClientApp.csproj +++ b/TravelCompany/TravelCompanyClientApp/TravelCompanyClientApp.csproj @@ -8,12 +8,10 @@ - - diff --git a/TravelCompany/TravelCompanyClientApp/Views/Home/Create.cshtml b/TravelCompany/TravelCompanyClientApp/Views/Home/Create.cshtml index 877bfb5..cf64bfe 100644 --- a/TravelCompany/TravelCompanyClientApp/Views/Home/Create.cshtml +++ b/TravelCompany/TravelCompanyClientApp/Views/Home/Create.cshtml @@ -1,37 +1,30 @@ @{ ViewData["Title"] = "Create"; } -

Создание заказа

-
Путёвка:
+
Изделие:
- +
Количество:
-
- -
+
Сумма:
-
- -
+
-
- -
+
+ - + + + @ViewData["Title"] - TravelCompanyClientApp + + + -
- -
-
-
- @RenderBody() -
-
- - - @RenderSection("Scripts", required: false) +
+ +
+
+
+ @RenderBody() +
+
+ +
+
+ © 2024 - TravelCompanyClientApp - Privacy +
+
+ + + + @await RenderSectionAsync("Scripts", required: false) - \ No newline at end of file + diff --git a/TravelCompany/TravelCompanyClientApp/appsettings.json b/TravelCompany/TravelCompanyClientApp/appsettings.json index 0ef371c..0a6b5f3 100644 --- a/TravelCompany/TravelCompanyClientApp/appsettings.json +++ b/TravelCompany/TravelCompanyClientApp/appsettings.json @@ -6,5 +6,5 @@ } }, "AllowedHosts": "*", - "IPAddress": "http://localhost:5189" + "IPAddress": "http://localhost:5247/" } diff --git a/TravelCompany/TravelCompanyContracts/ViewModels/OrderViewModel.cs b/TravelCompany/TravelCompanyContracts/ViewModels/OrderViewModel.cs index bf581b8..bc1f117 100644 --- a/TravelCompany/TravelCompanyContracts/ViewModels/OrderViewModel.cs +++ b/TravelCompany/TravelCompanyContracts/ViewModels/OrderViewModel.cs @@ -20,7 +20,7 @@ namespace TravelCompanyContracts.ViewModels public int ClientId { get; set; } [DisplayName("Клиент")] public string ClientFIO { get; set; } = string.Empty; - [DisplayName("Мороженное")] + [DisplayName("Путёвка")] public string TravelName { get; set; } = string.Empty; [DisplayName("Количество")] public int Count { get; set; } diff --git a/TravelCompany/TravelCompanyDatabaseImplement/Implements/ClientStorage.cs b/TravelCompany/TravelCompanyDatabaseImplement/Implements/ClientStorage.cs index 4abc464..c012aa8 100644 --- a/TravelCompany/TravelCompanyDatabaseImplement/Implements/ClientStorage.cs +++ b/TravelCompany/TravelCompanyDatabaseImplement/Implements/ClientStorage.cs @@ -3,6 +3,11 @@ using TravelCompanyContracts.SearchModels; using TravelCompanyContracts.StoragesContracts; using TravelCompanyContracts.ViewModels; using TravelCompanyDatabaseImplement.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; namespace TravelCompanyDatabaseImplement.Implements { diff --git a/TravelCompany/TravelCompanyDatabaseImplement/Models/Order.cs b/TravelCompany/TravelCompanyDatabaseImplement/Models/Order.cs index f2b212b..837eedc 100644 --- a/TravelCompany/TravelCompanyDatabaseImplement/Models/Order.cs +++ b/TravelCompany/TravelCompanyDatabaseImplement/Models/Order.cs @@ -5,14 +5,6 @@ using TravelCompanyDataModels.Models; using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using TravelCompanyContracts.BindingModels; -using TravelCompanyContracts.ViewModels; -using TravelCompanyDatabaseImplement.Models; -using TravelCompanyDataModels.Enums; -using TravelCompanyDataModels.Models; namespace TravelCompanyDatabaseImplement.Models { diff --git a/TravelCompany/TravelCompanyRestApi/Properties/launchSettings.json b/TravelCompany/TravelCompanyRestApi/Properties/launchSettings.json index 6eaf61e..65f2ea9 100644 --- a/TravelCompany/TravelCompanyRestApi/Properties/launchSettings.json +++ b/TravelCompany/TravelCompanyRestApi/Properties/launchSettings.json @@ -4,8 +4,8 @@ "windowsAuthentication": false, "anonymousAuthentication": true, "iisExpress": { - "applicationUrl": "http://localhost:54003", - "sslPort": 44386 + "applicationUrl": "http://localhost:27763", + "sslPort": 44336 } }, "profiles": { @@ -14,7 +14,7 @@ "dotnetRunMessages": true, "launchBrowser": true, "launchUrl": "swagger", - "applicationUrl": "https://localhost:7040;http://localhost:5297", + "applicationUrl": "https://localhost:7056;http://localhost:5247", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" } diff --git a/TravelCompany/TravelCompanyRestApi/TravelCompanyRestApi.csproj b/TravelCompany/TravelCompanyRestApi/TravelCompanyRestApi.csproj index 368418c..b338d3a 100644 --- a/TravelCompany/TravelCompanyRestApi/TravelCompanyRestApi.csproj +++ b/TravelCompany/TravelCompanyRestApi/TravelCompanyRestApi.csproj @@ -7,7 +7,7 @@ - + diff --git a/TravelCompany/TravelCompanyRestApi/log4net.config b/TravelCompany/TravelCompanyRestApi/log4net.config index 9b55807..fbbf5db 100644 --- a/TravelCompany/TravelCompanyRestApi/log4net.config +++ b/TravelCompany/TravelCompanyRestApi/log4net.config @@ -1,7 +1,7 @@ - + - +