diff --git a/DatabaseImplement/Implements/UserStorage.cs b/DatabaseImplement/Implements/UserStorage.cs index a9bdfc5..7622895 100644 --- a/DatabaseImplement/Implements/UserStorage.cs +++ b/DatabaseImplement/Implements/UserStorage.cs @@ -1,6 +1,8 @@ using Contracts.BindingModels; using Contracts.SearchModels; using Contracts.StorageContracts; +using DatabaseImplement.Models; +using Microsoft.EntityFrameworkCore; using System; using System.Collections.Generic; using System.Linq; @@ -39,6 +41,7 @@ namespace DatabaseImplement.Implements } var context = new Database(); return context.Users + .Include(u => u.Role) .FirstOrDefault(u => u.Equals(model)) ?.GetBindingModel(); } @@ -48,7 +51,9 @@ namespace DatabaseImplement.Implements var context = new Database(); if (model is null) { - return context.Users.Select(r => r.GetBindingModel()); + return context.Users + .Include(u => u.Role) + .Select(r => r.GetBindingModel()); } if (model.Id is null && model.Email is null) { @@ -56,6 +61,7 @@ namespace DatabaseImplement.Implements } return context.Users .Where(u => u.Equals(model)) + .Include(u => u.Role) .Select(r => r.GetBindingModel()); } @@ -77,7 +83,9 @@ namespace DatabaseImplement.Implements public UserBindingModel? Update(UserBindingModel model) { var context = new Database(); - var user = context.Users.FirstOrDefault(u => u.Id == model.Id); + var user = context.Users + .Include(u => u.Role) + .FirstOrDefault(u => u.Id == model.Id); if (user is null) {