This commit is contained in:
kagbie3nn@mail.ru 2024-05-31 00:21:54 +04:00
parent 0b39a273a7
commit 5e5d8d588c
6 changed files with 13 additions and 9 deletions

View File

@ -2,6 +2,7 @@
using Newtonsoft.Json;
using System.Net.Http.Headers;
using System.Text;
namespace ZooClientApp
{
public static class APIClient

View File

@ -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<EmployeeViewModel> GetFilteredList(EmployeeSearchModel model)
{

View File

@ -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<T>(result);
}
}
else
{
throw new Exception(result);
}
}
}
}
public static void PostRequest<T>(string requestUrl, T model)
{
var json = JsonConvert.SerializeObject(model);

View File

@ -22,7 +22,7 @@ namespace ZooShowEmployeeApp.Controllers
return Redirect("~/Home/Enter");
}
return
View(APIEmployee.GetRequest<List<RouteViewModel>>($"api/main/getorders?clientId={APIEmployee.Employee.Id}"));
View(APIEmployee.GetRequest<List<RouteViewModel>>($"api/main/getroutes?EmployeeId={APIEmployee.Employee.Id}"));
}
[HttpGet]

View File

@ -12,6 +12,7 @@
<ItemGroup>
<ProjectReference Include="..\ZooBusinessLogic\ZooBusinessLogic.csproj" />
<ProjectReference Include="..\ZooContracts\ZooContracts.csproj" />
<ProjectReference Include="..\ZooDataBaseImplement\ZooDataBaseImplement.csproj" />
</ItemGroup>

View File

@ -6,6 +6,6 @@
}
},
"AllowedHosts": "*",
"IPAddress": "http://localhost:7230/"
"IPAddress": "http://localhost:5244/"
}