base logic #5

Merged
mfnefd merged 25 commits from registration into main 2024-06-10 12:27:55 +04:00
Showing only changes of commit c3dd4384ff - Show all commits

View File

@ -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)
{