This commit is contained in:
Danil Markov 2023-04-07 19:38:26 +04:00
parent 2bd66c7925
commit 9bf66b97c4

View File

@ -20,8 +20,7 @@ namespace UniversityDataBaseImplemet.Implements
{
using var context = new Database();
var user = context.User
.Include(record => record.Login)
.Include(record => record.RoleId)
.Include(record => record.Role)
.FirstOrDefault(record => record.Id.Equals(model.Id));
if (user == null)
{
@ -40,8 +39,7 @@ namespace UniversityDataBaseImplemet.Implements
}
using var context = new Database();
return context.User
.Include(record => record.Login)
.Include(record => record.Id)
.Include(record => record.Role)
.FirstOrDefault(record => record.Id.Equals(model.Id))
?.GetViewModel;
}
@ -52,8 +50,7 @@ namespace UniversityDataBaseImplemet.Implements
if (model.Id.HasValue)
{
return context.User
.Include(record => record.Login)
.Include(record => record.RoleId)
.Include(record => record.Role)
.Where(record => record.Id.Equals(model.Id))
.Select(record => record.GetViewModel)
.ToList();
@ -65,8 +62,7 @@ namespace UniversityDataBaseImplemet.Implements
{
using var context = new Database();
return context.User
.Include(record => record.Login)
.Include(record => record.RoleId)
.Include(record => record.Role)
.Select(record => record.GetViewModel)
.ToList();
}
@ -91,8 +87,7 @@ namespace UniversityDataBaseImplemet.Implements
try
{
var user = context.User
.Include(record => record.Login)
.Include(record => record.RoleId)
.Include(record => record.Role)
.FirstOrDefault(record => record.Id.Equals(model.Id));
if (user == null)
{