empl
This commit is contained in:
parent
0b39a273a7
commit
5e5d8d588c
@ -2,6 +2,7 @@
|
||||
using Newtonsoft.Json;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Text;
|
||||
|
||||
namespace ZooClientApp
|
||||
{
|
||||
public static class APIClient
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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);
|
||||
|
@ -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]
|
||||
|
@ -12,6 +12,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\ZooBusinessLogic\ZooBusinessLogic.csproj" />
|
||||
<ProjectReference Include="..\ZooContracts\ZooContracts.csproj" />
|
||||
<ProjectReference Include="..\ZooDataBaseImplement\ZooDataBaseImplement.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
|
@ -6,6 +6,6 @@
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*",
|
||||
"IPAddress": "http://localhost:7230/"
|
||||
"IPAddress": "http://localhost:5244/"
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user