diff --git a/git/JurasicZoo/ZooClientApp/APIClient.cs b/git/JurasicZoo/ZooClientApp/APIClient.cs index 308a038..5c40bb9 100644 --- a/git/JurasicZoo/ZooClientApp/APIClient.cs +++ b/git/JurasicZoo/ZooClientApp/APIClient.cs @@ -2,6 +2,7 @@ using Newtonsoft.Json; using System.Net.Http.Headers; using System.Text; + namespace ZooClientApp { public static class APIClient diff --git a/git/JurasicZoo/ZooDataBaseImplement/Implements/EmployeeStorage.cs b/git/JurasicZoo/ZooDataBaseImplement/Implements/EmployeeStorage.cs index 391c409..3e33447 100644 --- a/git/JurasicZoo/ZooDataBaseImplement/Implements/EmployeeStorage.cs +++ b/git/JurasicZoo/ZooDataBaseImplement/Implements/EmployeeStorage.cs @@ -32,14 +32,15 @@ namespace ZooDataBaseImplement.Implements } public EmployeeViewModel? GetElement(EmployeeSearchModel model) { - if (!model.Id.HasValue) + if (string.IsNullOrEmpty(model.Login) && string.IsNullOrEmpty(model.Password) && !model.Id.HasValue) { return null; } - using var context = new ZooDatabase(); - - return context.Employees.FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id))?.GetViewModel; + return context.Employees.FirstOrDefault(x => + (!string.IsNullOrEmpty(model.Login) && x.Login == model.Login && !string.IsNullOrEmpty(model.Password) && x.Password == model.Password) || + (model.Id.HasValue && x.Id == model.Id)) + ?.GetViewModel; } public List GetFilteredList(EmployeeSearchModel model) { diff --git a/git/JurasicZoo/ZooShowEmployeeApp/APIEmployee.cs b/git/JurasicZoo/ZooShowEmployeeApp/APIEmployee.cs index 0fba6f7..a31f41c 100644 --- a/git/JurasicZoo/ZooShowEmployeeApp/APIEmployee.cs +++ b/git/JurasicZoo/ZooShowEmployeeApp/APIEmployee.cs @@ -20,15 +20,16 @@ namespace ZooShowEmployeeApp { var response = _employee.GetAsync(requestUrl); var result = response.Result.Content.ReadAsStringAsync().Result; + if (response.Result.IsSuccessStatusCode) { return JsonConvert.DeserializeObject(result); - } + } else { throw new Exception(result); - } - } + } +} public static void PostRequest(string requestUrl, T model) { var json = JsonConvert.SerializeObject(model); diff --git a/git/JurasicZoo/ZooShowEmployeeApp/Controllers/HomeController.cs b/git/JurasicZoo/ZooShowEmployeeApp/Controllers/HomeController.cs index 2ef7739..2ab4135 100644 --- a/git/JurasicZoo/ZooShowEmployeeApp/Controllers/HomeController.cs +++ b/git/JurasicZoo/ZooShowEmployeeApp/Controllers/HomeController.cs @@ -22,7 +22,7 @@ namespace ZooShowEmployeeApp.Controllers return Redirect("~/Home/Enter"); } return - View(APIEmployee.GetRequest>($"api/main/getorders?clientId={APIEmployee.Employee.Id}")); + View(APIEmployee.GetRequest>($"api/main/getroutes?EmployeeId={APIEmployee.Employee.Id}")); } [HttpGet] diff --git a/git/JurasicZoo/ZooShowEmployeeApp/ZooShowEmployeeApp.csproj b/git/JurasicZoo/ZooShowEmployeeApp/ZooShowEmployeeApp.csproj index 830a9e5..b85ba1b 100644 --- a/git/JurasicZoo/ZooShowEmployeeApp/ZooShowEmployeeApp.csproj +++ b/git/JurasicZoo/ZooShowEmployeeApp/ZooShowEmployeeApp.csproj @@ -12,6 +12,7 @@ + diff --git a/git/JurasicZoo/ZooShowEmployeeApp/appsettings.json b/git/JurasicZoo/ZooShowEmployeeApp/appsettings.json index 685c337..8dbf23b 100644 --- a/git/JurasicZoo/ZooShowEmployeeApp/appsettings.json +++ b/git/JurasicZoo/ZooShowEmployeeApp/appsettings.json @@ -6,6 +6,6 @@ } }, "AllowedHosts": "*", - "IPAddress": "http://localhost:7230/" + "IPAddress": "http://localhost:5244/" }