From c41f0e635ffa9774362de0e6bcd73bca71c42d0d Mon Sep 17 00:00:00 2001 From: Zakharov_Rostislav Date: Mon, 13 May 2024 12:37:11 +0400 Subject: [PATCH] fix client app --- CarShowroom/CarShowroomDataModels/Views/CarView.cs | 3 ++- CarShowroom/CarShowroomDataModels/Views/ClientView.cs | 5 +++-- .../CarShowroomDataModels/Views/EmployeeView.cs | 3 ++- CarShowroom/CarShowroomDataModels/Views/MakeView.cs | 5 +++-- CarShowroom/CarShowroomDataModels/Views/ModelView.cs | 5 +++-- CarShowroom/CarShowroomDataModels/Views/SaleView.cs | 3 ++- .../CarShowroomDataModels/Views/ServiceView.cs | 5 +++-- CarShowroom/CarShowroomManagerApp/APIClient.cs | 11 +++-------- .../Controllers/HomeController.cs | 3 +-- CarShowroom/CarShowroomManagerApp/Program.cs | 9 ++++++--- .../CarShowroomManagerApp/Views/Home/Clients.cshtml | 4 ++-- .../CarShowroomManagerApp/Views/Home/Enter.cshtml | 4 ++-- 12 files changed, 32 insertions(+), 28 deletions(-) diff --git a/CarShowroom/CarShowroomDataModels/Views/CarView.cs b/CarShowroom/CarShowroomDataModels/Views/CarView.cs index 4536110..cd3f7a9 100644 --- a/CarShowroom/CarShowroomDataModels/Views/CarView.cs +++ b/CarShowroom/CarShowroomDataModels/Views/CarView.cs @@ -35,5 +35,6 @@ namespace CarShowroomDataModels.Views ModelId = model.ModelId; IsSaled = model.IsSaled; } - } + public CarView() { } + } } diff --git a/CarShowroom/CarShowroomDataModels/Views/ClientView.cs b/CarShowroom/CarShowroomDataModels/Views/ClientView.cs index a9af84c..06712b7 100644 --- a/CarShowroom/CarShowroomDataModels/Views/ClientView.cs +++ b/CarShowroom/CarShowroomDataModels/Views/ClientView.cs @@ -20,6 +20,7 @@ namespace CarShowroomDataModels.Views Id = model.Id; Name = model.Name; PhoneNumber = model.PhoneNumber; - } - } + } + public ClientView() { } + } } diff --git a/CarShowroom/CarShowroomDataModels/Views/EmployeeView.cs b/CarShowroom/CarShowroomDataModels/Views/EmployeeView.cs index a0eeb82..abec8c8 100644 --- a/CarShowroom/CarShowroomDataModels/Views/EmployeeView.cs +++ b/CarShowroom/CarShowroomDataModels/Views/EmployeeView.cs @@ -24,5 +24,6 @@ namespace CarShowroomDataModels.Views Email = model.Email; Password = model.Password; } - } + public EmployeeView() {} + } } diff --git a/CarShowroom/CarShowroomDataModels/Views/MakeView.cs b/CarShowroom/CarShowroomDataModels/Views/MakeView.cs index 71182b4..19eb02f 100644 --- a/CarShowroom/CarShowroomDataModels/Views/MakeView.cs +++ b/CarShowroom/CarShowroomDataModels/Views/MakeView.cs @@ -17,6 +17,7 @@ namespace CarShowroomDataModels.Views { Id = model.Id; Name = model.Name; - } - } + } + public MakeView() { } + } } diff --git a/CarShowroom/CarShowroomDataModels/Views/ModelView.cs b/CarShowroom/CarShowroomDataModels/Views/ModelView.cs index 98f5a6b..6527697 100644 --- a/CarShowroom/CarShowroomDataModels/Views/ModelView.cs +++ b/CarShowroom/CarShowroomDataModels/Views/ModelView.cs @@ -24,6 +24,7 @@ namespace CarShowroomDataModels.Views Name = model.Name; Price = model.Price; MakeId = model.MakeId; - } - } + } + public ModelView() { } + } } diff --git a/CarShowroom/CarShowroomDataModels/Views/SaleView.cs b/CarShowroom/CarShowroomDataModels/Views/SaleView.cs index a6d5fe5..783060e 100644 --- a/CarShowroom/CarShowroomDataModels/Views/SaleView.cs +++ b/CarShowroom/CarShowroomDataModels/Views/SaleView.cs @@ -46,5 +46,6 @@ namespace CarShowroomDataModels.Views ClientId = model.ClientId; EmployeeId = model.EmployeeId; } - } + public SaleView() { } + } } diff --git a/CarShowroom/CarShowroomDataModels/Views/ServiceView.cs b/CarShowroom/CarShowroomDataModels/Views/ServiceView.cs index f6371de..e2b6adc 100644 --- a/CarShowroom/CarShowroomDataModels/Views/ServiceView.cs +++ b/CarShowroom/CarShowroomDataModels/Views/ServiceView.cs @@ -17,6 +17,7 @@ namespace CarShowroomDataModels.Views Id = model.Id; Name = model.Name; Cost = model.Cost; - } - } + } + public ServiceView() { } + } } diff --git a/CarShowroom/CarShowroomManagerApp/APIClient.cs b/CarShowroom/CarShowroomManagerApp/APIClient.cs index d1d15f3..ae544bc 100644 --- a/CarShowroom/CarShowroomManagerApp/APIClient.cs +++ b/CarShowroom/CarShowroomManagerApp/APIClient.cs @@ -11,14 +11,9 @@ namespace CarShowroomManagerApp private static readonly HttpClient _client = new(); public static EmployeeView? Client { get; set; } = null; public static void Connect(IConfiguration configuration) - { - string? ip = configuration["IPAddress"]; - if (ip == null) - { - throw new Exception("RestApi application's IPAddress is undefined"); - } - _client.BaseAddress = new Uri(ip); - _client.DefaultRequestHeaders.Accept.Clear(); + { + _client.BaseAddress = new Uri(configuration["IPAddress"]); + _client.DefaultRequestHeaders.Accept.Clear(); _client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); } diff --git a/CarShowroom/CarShowroomManagerApp/Controllers/HomeController.cs b/CarShowroom/CarShowroomManagerApp/Controllers/HomeController.cs index 6512309..1b6ae8f 100644 --- a/CarShowroom/CarShowroomManagerApp/Controllers/HomeController.cs +++ b/CarShowroom/CarShowroomManagerApp/Controllers/HomeController.cs @@ -56,7 +56,7 @@ namespace CarShowroomManagerApp.Controllers public void Enter(string login, string password) { if (string.IsNullOrEmpty(login) || - string.IsNullOrEmpty(password)) + string.IsNullOrEmpty(password)) { throw new Exception("Введите логин и пароль"); } @@ -124,7 +124,6 @@ namespace CarShowroomManagerApp.Controllers Name = name, PhoneNumber = phonenumber }); - Response.Redirect("Enter"); return; } public IActionResult ClientUpdate() diff --git a/CarShowroom/CarShowroomManagerApp/Program.cs b/CarShowroom/CarShowroomManagerApp/Program.cs index c621813..365e773 100644 --- a/CarShowroom/CarShowroomManagerApp/Program.cs +++ b/CarShowroom/CarShowroomManagerApp/Program.cs @@ -1,3 +1,5 @@ +using CarShowroomDataModels.Models; + namespace CarShowroomManagerApp { public class Program @@ -8,11 +10,12 @@ namespace CarShowroomManagerApp // Add services to the container. builder.Services.AddControllersWithViews(); + var app = builder.Build(); - var app = builder.Build(); + ApiClient.Connect(builder.Configuration); - // Configure the HTTP request pipeline. - if (!app.Environment.IsDevelopment()) + // Configure the HTTP request pipeline. + if (!app.Environment.IsDevelopment()) { app.UseExceptionHandler("/Home/Error"); // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. diff --git a/CarShowroom/CarShowroomManagerApp/Views/Home/Clients.cshtml b/CarShowroom/CarShowroomManagerApp/Views/Home/Clients.cshtml index 1bb97b8..832221b 100644 --- a/CarShowroom/CarShowroomManagerApp/Views/Home/Clients.cshtml +++ b/CarShowroom/CarShowroomManagerApp/Views/Home/Clients.cshtml @@ -14,8 +14,8 @@ return; }

- Создать перевод - Обновить перевод + Зарегистрировать клиента + Обновить данные клиента

diff --git a/CarShowroom/CarShowroomManagerApp/Views/Home/Enter.cshtml b/CarShowroom/CarShowroomManagerApp/Views/Home/Enter.cshtml index 53ca16d..f516d93 100644 --- a/CarShowroom/CarShowroomManagerApp/Views/Home/Enter.cshtml +++ b/CarShowroom/CarShowroomManagerApp/Views/Home/Enter.cshtml @@ -7,11 +7,11 @@
Логин:
-
+
Пароль:
-
+