base logic #5
@ -1,6 +1,8 @@
|
|||||||
using Contracts.BindingModels;
|
using Contracts.BindingModels;
|
||||||
using Contracts.SearchModels;
|
using Contracts.SearchModels;
|
||||||
using Contracts.StorageContracts;
|
using Contracts.StorageContracts;
|
||||||
|
using DatabaseImplement.Models;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@ -39,6 +41,7 @@ namespace DatabaseImplement.Implements
|
|||||||
}
|
}
|
||||||
var context = new Database();
|
var context = new Database();
|
||||||
return context.Users
|
return context.Users
|
||||||
|
.Include(u => u.Role)
|
||||||
.FirstOrDefault(u => u.Equals(model))
|
.FirstOrDefault(u => u.Equals(model))
|
||||||
?.GetBindingModel();
|
?.GetBindingModel();
|
||||||
}
|
}
|
||||||
@ -48,7 +51,9 @@ namespace DatabaseImplement.Implements
|
|||||||
var context = new Database();
|
var context = new Database();
|
||||||
if (model is null)
|
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)
|
if (model.Id is null && model.Email is null)
|
||||||
{
|
{
|
||||||
@ -56,6 +61,7 @@ namespace DatabaseImplement.Implements
|
|||||||
}
|
}
|
||||||
return context.Users
|
return context.Users
|
||||||
.Where(u => u.Equals(model))
|
.Where(u => u.Equals(model))
|
||||||
|
.Include(u => u.Role)
|
||||||
.Select(r => r.GetBindingModel());
|
.Select(r => r.GetBindingModel());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -77,7 +83,9 @@ namespace DatabaseImplement.Implements
|
|||||||
public UserBindingModel? Update(UserBindingModel model)
|
public UserBindingModel? Update(UserBindingModel model)
|
||||||
{
|
{
|
||||||
var context = new Database();
|
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)
|
if (user is null)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user