forked from ddrilling/AsbCloudServer
48 lines
1.2 KiB
C#
48 lines
1.2 KiB
C#
using AsbCloudApp.Data;
|
|
using AsbCloudDb.Model;
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
var options = new DbContextOptionsBuilder<AsbCloudDbContext>()
|
|
.UseNpgsql("Host=localhost;Database=experiments;Username=postgres;Password=q;Persist Security Info=True;Include Error Detail=True")
|
|
.Options;
|
|
var context = new AsbCloudDbContext(options);
|
|
|
|
var rels = context.RelationUserRoleUserRoles.Include(r=>r.Role).Include(r => r.IncludeRole);
|
|
|
|
IEnumerable<UserRoleDto> GetIncludedRole(int id)
|
|
{
|
|
var res = context.UserRoles
|
|
.Include(r=>r.RelationUserRoleUserRoles)
|
|
.Where(r=>r.Id == id)
|
|
.SelectMany(r=>r.);
|
|
return rels.Where(r => r.Id == id).;
|
|
}
|
|
|
|
UserRoleDto Convert(UserRole role)
|
|
{
|
|
if (role is null)
|
|
return null;
|
|
|
|
var res = new UserRoleDto
|
|
{
|
|
Id = role.Id,
|
|
Caption = role.Caption,
|
|
IdType = role.IdType,
|
|
Permissions = role.RelationUserRolePermissions?.Select(r => r.Permission).ToList(),
|
|
};
|
|
}
|
|
|
|
PermissionDto Convert(Permission permission)
|
|
{
|
|
if (permission is null)
|
|
return null;
|
|
return new PermissionDto
|
|
{
|
|
Name = permission.Name,
|
|
Id = permission.Id,
|
|
Description = permission.Description
|
|
};
|
|
}
|
|
|
|
Console.WriteLine("Hello, World!");
|