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