Compare commits
12 Commits
1b2e3b8abd
...
6b2a849824
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6b2a849824 | ||
|
|
c604e5c5ef | ||
|
|
b6cdb80162 | ||
|
|
28b2de19ae | ||
|
|
c61502f80d | ||
|
|
dd1d911354 | ||
|
|
f38c351cc8 | ||
|
|
90f55b35ee | ||
|
|
e3f4b78083 | ||
|
|
19ba6f0da9 | ||
|
|
21d7507726 | ||
|
|
6b8239485e |
@@ -1 +1,18 @@
|
||||
<app-module-table #moduleTable></app-module-table>
|
||||
<div class="container-fluid text-center">
|
||||
<div class="row m-0 p-0">
|
||||
<div class="col-6">
|
||||
<mat-tab-group>
|
||||
<mat-tab label="Module">
|
||||
<app-module-table #moduleTable [onSelectedRows]="modulesOnSelectedRows"></app-module-table>
|
||||
</mat-tab>
|
||||
</mat-tab-group>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<mat-tab-group>
|
||||
<mat-tab label="Benutzer">
|
||||
<app-user-table #userTable [initData]="initWithoutData"></app-user-table>
|
||||
</mat-tab>
|
||||
</mat-tab-group>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -1,23 +1,40 @@
|
||||
import { AfterViewInit, Component, ViewChild } from '@angular/core';
|
||||
import { ModuleTableComponent } from '../../components/tables/module-table/module-table.component';
|
||||
import { RefreshService } from '../../services/refresh.service';
|
||||
import { MatTabsModule } from '@angular/material/tabs';
|
||||
import { UserTableComponent } from '../tables/user-table/user-table.component';
|
||||
import { GuiSelectedRow } from '@generic-ui/ngx-grid';
|
||||
|
||||
@Component({
|
||||
standalone: true,
|
||||
imports: [ModuleTableComponent],
|
||||
imports: [ModuleTableComponent, MatTabsModule, UserTableComponent],
|
||||
selector: 'app-module',
|
||||
templateUrl: './module.component.html',
|
||||
styleUrl: './module.component.css'
|
||||
})
|
||||
export class ModuleComponent implements AfterViewInit {
|
||||
constructor(private refreshService: RefreshService) { }
|
||||
|
||||
private uModuleId = null;
|
||||
|
||||
constructor(private refreshService: RefreshService) { }
|
||||
initWithoutData = () => { }
|
||||
ngAfterViewInit(): void {
|
||||
this.refreshService.removeAll()
|
||||
this.refreshService.add(() => {
|
||||
this.moduleTable.fetchData();
|
||||
if(this.uModuleId)
|
||||
this.userTable.fetchDataByModuleId(this.uModuleId);
|
||||
});
|
||||
}
|
||||
|
||||
@ViewChild("moduleTable") moduleTable!: ModuleTableComponent;
|
||||
@ViewChild("userTable") userTable!: UserTableComponent;
|
||||
|
||||
modulesOnSelectedRows = (rows: GuiSelectedRow[]) => {
|
||||
if(rows.length > 0){
|
||||
this.uModuleId = rows[0].source.id;
|
||||
if(this.uModuleId)
|
||||
this.userTable.fetchDataByGroupId(this.uModuleId);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -127,7 +127,7 @@ export class BaseTableComponent<TModel, TApiService extends ApiService<TModel>>
|
||||
return this.mainGrid.api;
|
||||
}
|
||||
|
||||
set source(data: TModel[]) {
|
||||
set source(data: any[]) {
|
||||
this.api.setSource(data)
|
||||
}
|
||||
|
||||
|
||||
@@ -27,8 +27,6 @@ export class DirUserTableComponent extends BaseTableComponent<DirUser, DirUserSe
|
||||
next: async (response: DirUser[]) => {
|
||||
|
||||
const usernames = (await firstValueFrom(this.uService.getAll())).map(u => u.username)
|
||||
console.log(usernames)
|
||||
console.log(response)
|
||||
this.source = response.filter(user => user.samaccountname?.length && !usernames.includes(user.samaccountname[0]));
|
||||
this.loading = false;
|
||||
},
|
||||
|
||||
@@ -7,6 +7,7 @@ import { ColorModeService } from '../../../services/color-mode.service';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
import { env } from '../../../../environments/environment';
|
||||
import { GroupOfUserService } from '../../../services/group-of-user.service';
|
||||
|
||||
@Component({
|
||||
standalone: true,
|
||||
@@ -16,8 +17,13 @@ import { env } from '../../../../environments/environment';
|
||||
styleUrl: './group-table.component.css'
|
||||
})
|
||||
export class GroupTableComponent extends BaseTableComponent<Group, GroupService> {
|
||||
constructor(
|
||||
service: GroupService, cModeService: ColorModeService) {
|
||||
constructor(service: GroupService, cModeService: ColorModeService, private gouService: GroupOfUserService) {
|
||||
super(service, env.columnNames.group.complete, cModeService)
|
||||
}
|
||||
|
||||
fetchDataByUsername(username: string) {
|
||||
this.gouService.getByUsername(username)
|
||||
.then(gos_list => gos_list.map(gos => gos.group))
|
||||
.then(groups => this.source = groups)
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,7 @@ import { ColorModeService } from '../../../services/color-mode.service';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
import { env } from '../../../../environments/environment';
|
||||
import { ModuleOfUserService } from '../../../services/module-of-user.service';
|
||||
|
||||
@Component({
|
||||
standalone: true,
|
||||
@@ -17,7 +18,13 @@ import { env } from '../../../../environments/environment';
|
||||
})
|
||||
export class ModuleTableComponent extends BaseTableComponent<Module, ModuleService> {
|
||||
constructor(
|
||||
service: ModuleService, cModeService: ColorModeService) {
|
||||
service: ModuleService, cModeService: ColorModeService, private mouService: ModuleOfUserService) {
|
||||
super(service, env.columnNames.module, cModeService)
|
||||
}
|
||||
|
||||
fetchDataByUsername(username: string) {
|
||||
this.mouService.getByUsername(username)
|
||||
.then(mou_list => mou_list.map(mou => mou.module))
|
||||
.then(modules => this.source = modules)
|
||||
}
|
||||
}
|
||||
@@ -1 +1,26 @@
|
||||
<app-user-table #userTable [cellEditing]="cellEditing"></app-user-table>
|
||||
<div class="container-fluid text-center">
|
||||
<div class="row m-0 p-0">
|
||||
<div class="col-6">
|
||||
<mat-tab-group>
|
||||
<mat-tab label="Benutzer">
|
||||
<app-user-table #userTable [onSelectedRows]="usersOnSelectedRows"
|
||||
[cellEditing]="cellEditing"></app-user-table>
|
||||
</mat-tab>
|
||||
</mat-tab-group>
|
||||
</div>
|
||||
<div class="col-3">
|
||||
<mat-tab-group>
|
||||
<mat-tab label="Gruppen">
|
||||
<app-group-table #groupTable [initData]="initWithoutData"></app-group-table>
|
||||
</mat-tab>
|
||||
</mat-tab-group>
|
||||
</div>
|
||||
<div class="col-3">
|
||||
<mat-tab-group>
|
||||
<mat-tab label="Module">
|
||||
<app-module-table #moduleTable [initData]="initWithoutData"></app-module-table>
|
||||
</mat-tab>
|
||||
</mat-tab-group>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -1,34 +1,58 @@
|
||||
import { AfterViewInit, Component, ViewChild } from '@angular/core';
|
||||
import { GuiCellEdit } from '@generic-ui/ngx-grid';
|
||||
import { GuiCellEdit, GuiSelectedRow } from '@generic-ui/ngx-grid';
|
||||
import { UserTableComponent } from '../tables/user-table/user-table.component';
|
||||
import { RefreshService } from '../../services/refresh.service';
|
||||
import { MatTabsModule } from '@angular/material/tabs';
|
||||
import { GroupTableComponent } from '../../components/tables/group-table/group-table.component';
|
||||
import { ModuleTableComponent } from '../../components/tables/module-table/module-table.component';
|
||||
|
||||
@Component({
|
||||
standalone: true,
|
||||
imports: [UserTableComponent],
|
||||
imports: [UserTableComponent, MatTabsModule, GroupTableComponent, ModuleTableComponent],
|
||||
selector: 'app-user',
|
||||
templateUrl: './user.component.html',
|
||||
styleUrl: './user.component.css'
|
||||
})
|
||||
export class UserComponent implements AfterViewInit {
|
||||
initWithoutData = () => { }
|
||||
|
||||
cellEditing: GuiCellEdit = {
|
||||
enabled: true,
|
||||
rowEdit: (value: any, item: any, index: number) => {
|
||||
return Boolean(index % 2);
|
||||
return true;
|
||||
},
|
||||
cellEdit: (value: any, item: any, index: number) => {
|
||||
return Boolean(index % 5);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private sUsername = null;
|
||||
|
||||
constructor(private refreshService: RefreshService) { }
|
||||
|
||||
ngAfterViewInit(): void {
|
||||
this.refreshService.removeAll()
|
||||
this.refreshService.add(() => {
|
||||
this.userTable.fetchData();
|
||||
if (this.sUsername != null){
|
||||
this.groupTable.fetchDataByUsername(this.sUsername);
|
||||
this.moduleTable.fetchDataByUsername(this.sUsername)
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ViewChild("userTable") userTable!: UserTableComponent
|
||||
@ViewChild("groupTable") groupTable!: GroupTableComponent;
|
||||
@ViewChild("moduleTable") moduleTable!: ModuleTableComponent;
|
||||
|
||||
usersOnSelectedRows = (rows: GuiSelectedRow[]) => {
|
||||
if (rows.length > 0) {
|
||||
this.sUsername = rows[0].source.username;
|
||||
|
||||
if (this.sUsername != null){
|
||||
this.groupTable.fetchDataByUsername(this.sUsername);
|
||||
this.moduleTable.fetchDataByUsername(this.sUsername)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
import { Component, Inject, OnInit } from '@angular/core';
|
||||
import { Router } from '@angular/router';
|
||||
import { AuthenticationService } from '../services/authentication.service';
|
||||
import { RefreshService } from '../services/refresh.service';
|
||||
|
||||
@Component({
|
||||
standalone: true,
|
||||
@@ -13,7 +14,8 @@ export class HomeComponent implements OnInit {
|
||||
username: string = '';
|
||||
password: string = '';
|
||||
|
||||
constructor(private authService: AuthenticationService, private router: Router) {
|
||||
constructor(private authService: AuthenticationService, private router: Router, rService: RefreshService) {
|
||||
rService.removeAll()
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
|
||||
@@ -40,6 +40,7 @@ export interface ModuleOfUser {
|
||||
comment?: string;
|
||||
addedWho?: string;
|
||||
changedWho?: string;
|
||||
module?: Module;
|
||||
}
|
||||
|
||||
export interface GroupOfUser {
|
||||
|
||||
@@ -94,7 +94,7 @@ html {
|
||||
display: block !important;
|
||||
}
|
||||
|
||||
.mat-icon:hover {
|
||||
.turn-360:hover {
|
||||
animation: rotate 1s ease forwards;
|
||||
}
|
||||
|
||||
@@ -105,4 +105,25 @@ html {
|
||||
100% {
|
||||
transform: rotate(360deg);
|
||||
}
|
||||
}
|
||||
|
||||
.scale-pulse {
|
||||
display: inline-block;
|
||||
transition: transform 1s ease;
|
||||
}
|
||||
|
||||
.scale-pulse:hover {
|
||||
animation: pulse 1s ease forwards;
|
||||
}
|
||||
|
||||
@keyframes pulse {
|
||||
0% {
|
||||
transform: scale(1);
|
||||
}
|
||||
50% {
|
||||
transform: scale(1.2);
|
||||
}
|
||||
100% {
|
||||
transform: scale(1);
|
||||
}
|
||||
}
|
||||
@@ -30,8 +30,11 @@
|
||||
<!-- Right menu -->
|
||||
<div class="navbar-collapse justify-content-end me-5">
|
||||
<a class="navbar-brand" [routerLink]="['/']">User Manager Portal</a>
|
||||
<button class="btn">
|
||||
<mat-icon class="scale-pulse">add_to_photos</mat-icon>
|
||||
</button>
|
||||
<button class="btn" (click)="refreshService.executeAll()">
|
||||
<mat-icon>sync</mat-icon>
|
||||
<mat-icon class="turn-360">sync</mat-icon>
|
||||
</button>
|
||||
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target=".navbar-collapse"
|
||||
aria-label="Toggle navigation" [attr.aria-expanded]="isExpanded" (click)="toggle()">
|
||||
|
||||
@@ -2,14 +2,14 @@ import { Injectable, Inject } from '@angular/core';
|
||||
import { HttpClient, HttpParams } from '@angular/common/http';
|
||||
import { GroupOfUser } from '../models/user-management.api.models';
|
||||
import { ApiService } from './user-management.api.service';
|
||||
import { Observable } from 'rxjs';
|
||||
import { Observable, firstValueFrom } from 'rxjs';
|
||||
import { UrlService } from './url.service';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class GroupOfUserService extends ApiService<GroupOfUser> {
|
||||
constructor(http: HttpClient, urlService : UrlService) {
|
||||
constructor(http: HttpClient, urlService: UrlService) {
|
||||
super(http, urlService.apiRoute.groupOfUser);
|
||||
}
|
||||
|
||||
@@ -29,4 +29,9 @@ export class GroupOfUserService extends ApiService<GroupOfUser> {
|
||||
|
||||
return this.http.get<GroupOfUser[]>(this.baseUrl, { params, withCredentials: true });
|
||||
}
|
||||
|
||||
async getByUsername(username: string): Promise<GroupOfUser[]> {
|
||||
const url = `${this.baseUrl}?username=${username}`;
|
||||
return await firstValueFrom(this.http.get<GroupOfUser[]>(url, { withCredentials: true }));
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@ import { Injectable, Inject } from '@angular/core';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { ModuleOfUser } from '../models/user-management.api.models';
|
||||
import { ApiService } from './user-management.api.service';
|
||||
import { Observable } from 'rxjs';
|
||||
import { Observable, firstValueFrom } from 'rxjs';
|
||||
import { UrlService } from './url.service';
|
||||
|
||||
@Injectable({
|
||||
@@ -17,4 +17,9 @@ export class ModuleOfUserService extends ApiService<ModuleOfUser> {
|
||||
const url = `${this.baseUrl}?moduleId=${moduleId}&userId=${userId}`;
|
||||
return this.http.delete<any>(url, { withCredentials: true });
|
||||
}
|
||||
|
||||
async getByUsername(username: string): Promise<ModuleOfUser[]> {
|
||||
const url = `${this.baseUrl}?username=${username}`;
|
||||
return await firstValueFrom(this.http.get<ModuleOfUser[]>(url, { withCredentials: true }));
|
||||
}
|
||||
}
|
||||
@@ -42,6 +42,14 @@ export const env = {
|
||||
{
|
||||
header: "Kommentar",
|
||||
field: "comment"
|
||||
},
|
||||
{
|
||||
header: "AD Sync",
|
||||
field: (group: any) => group.adSync ? "✓" : ""
|
||||
},
|
||||
{
|
||||
header: "Internal",
|
||||
field: (group: any) => group.internal ? "✓" : ""
|
||||
}
|
||||
],
|
||||
representative: [
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace DigitalData.UserManager.API.Controllers
|
||||
return await _service.DeleteAsyncByGroupUserId(groupId, userId).ThenAsync(Ok, IActionResult (m, n) =>
|
||||
{
|
||||
_logger.LogNotice(n);
|
||||
return BadRequest();
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -37,10 +37,17 @@ namespace DigitalData.UserManager.API.Controllers
|
||||
public override Task<IActionResult> GetAll() => base.GetAll();
|
||||
|
||||
[HttpGet]
|
||||
public async Task<IActionResult> GetAll([FromQuery]bool withUser = false, [FromQuery]bool withGroup = false)
|
||||
public async Task<IActionResult> GetAll([FromQuery]bool withUser = false, [FromQuery]bool withGroup = false, [FromQuery] string? username = null)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (username is not null)
|
||||
return await _service.ReadByUsernameAsync(username).ThenAsync(Ok, IActionResult (m, n) =>
|
||||
{
|
||||
_logger.LogNotice(n);
|
||||
return NotFound();
|
||||
});
|
||||
|
||||
return await _service.ReadAllAsyncWith(withUser, withGroup).ThenAsync(Ok, IActionResult (m, n) =>
|
||||
{
|
||||
_logger.LogNotice(n);
|
||||
|
||||
@@ -14,7 +14,24 @@ namespace DigitalData.UserManager.API.Controllers
|
||||
public ModuleOfUserController(ILogger<ModuleOfUserController> logger, IModuleOfUserService service) : base(logger, service)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
[NonAction]
|
||||
public override Task<IActionResult> GetAll() => base.GetAll();
|
||||
|
||||
[HttpGet]
|
||||
public async Task<IActionResult> GetAll(string? username = null)
|
||||
{
|
||||
|
||||
if (username is not null)
|
||||
return await _service.ReadByUserAsync(username).ThenAsync(Ok, IActionResult (m, n) =>
|
||||
{
|
||||
_logger.LogNotice(n);
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
});
|
||||
|
||||
return await base.GetAll();
|
||||
}
|
||||
|
||||
[HttpDelete]
|
||||
public async Task<IActionResult> Delete([FromQuery] int moduleId, [FromQuery]int userId)
|
||||
{
|
||||
|
||||
@@ -27,20 +27,44 @@
|
||||
},
|
||||
"NLog": {
|
||||
"throwConfigExceptions": true,
|
||||
"variables": {
|
||||
"logDirectory": "E:\\WebUserManager\\logs",
|
||||
"logFileNamePrefix": "${shortdate}-ECM.WebUserManager.Web"
|
||||
},
|
||||
"targets": {
|
||||
"logfile": {
|
||||
"infoLogs": {
|
||||
"type": "File",
|
||||
"fileName": "E:/WebUserManager/logs/${shortdate}.log"
|
||||
"fileName": "${logDirectory}\\${logFileNamePrefix}-Info.log",
|
||||
"maxArchiveDays": 30
|
||||
},
|
||||
"logconsole": {
|
||||
"type": "Console"
|
||||
"errorLogs": {
|
||||
"type": "File",
|
||||
"fileName": "${logDirectory}\\${logFileNamePrefix}-Error.log",
|
||||
"maxArchiveDays": 30
|
||||
},
|
||||
"criticalLogs": {
|
||||
"type": "File",
|
||||
"fileName": "${logDirectory}\\${logFileNamePrefix}-Critical.log",
|
||||
"maxArchiveDays": 30
|
||||
}
|
||||
},
|
||||
// Trace, Debug, Info, Warn, Error and *Fatal*
|
||||
"rules": [
|
||||
{
|
||||
"logger": "*",
|
||||
"minLevel": "Debug",
|
||||
"writeTo": "logfile,logconsole"
|
||||
"minLevel": "Info",
|
||||
"maxLevel": "Warn",
|
||||
"writeTo": "infoLogs"
|
||||
},
|
||||
{
|
||||
"logger": "*",
|
||||
"level": "Error",
|
||||
"writeTo": "errorLogs"
|
||||
},
|
||||
{
|
||||
"logger": "*",
|
||||
"level": "Fatal",
|
||||
"writeTo": "criticalLogs"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -12,5 +12,7 @@ namespace DigitalData.UserManager.Application.Contracts
|
||||
Task<DataResult<IEnumerable<GroupOfUserReadDto>>> ReadAllAsyncWith(bool user, bool group);
|
||||
|
||||
Task<Result> HasGroup(string username, string groupname, bool caseSensitive = true);
|
||||
|
||||
Task<DataResult<IEnumerable<GroupOfUserReadDto>>> ReadByUsernameAsync(string username);
|
||||
}
|
||||
}
|
||||
@@ -8,5 +8,7 @@ namespace DigitalData.UserManager.Application.Contracts
|
||||
public interface IModuleOfUserService : ICRUDService<ModuleOfUserCreateDto, ModuleOfUserReadDto, ModuleOfUserUpdateDto, ModuleOfUser, int>
|
||||
{
|
||||
Task<Result> DeleteAsyncByModuleUserId(int moduleId, int userId);
|
||||
|
||||
Task<DataResult<IEnumerable<ModuleOfUserReadDto>>> ReadByUserAsync(string username);
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,7 @@
|
||||
namespace DigitalData.UserManager.Application.DTOs.ModuleOfUser
|
||||
using DigitalData.UserManager.Application.DTOs.Module;
|
||||
using DigitalData.UserManager.Application.DTOs.User;
|
||||
|
||||
namespace DigitalData.UserManager.Application.DTOs.ModuleOfUser
|
||||
{
|
||||
public record ModuleOfUserReadDto(
|
||||
int Id,
|
||||
@@ -6,6 +9,8 @@
|
||||
int ModuleId,
|
||||
string? Comment,
|
||||
string? AddedWho,
|
||||
string? ChangedWho
|
||||
string? ChangedWho,
|
||||
UserReadDto User,
|
||||
ModuleDto? Module
|
||||
);
|
||||
}
|
||||
@@ -5,7 +5,6 @@ using DigitalData.UserManager.Application.Contracts;
|
||||
using DigitalData.UserManager.Application.DTOs.GroupOfUser;
|
||||
using DigitalData.UserManager.Domain.Entities;
|
||||
using DigitalData.UserManager.Infrastructure.Contracts;
|
||||
using Microsoft.Extensions.Localization;
|
||||
|
||||
namespace DigitalData.UserManager.Application.Services
|
||||
{
|
||||
@@ -63,5 +62,12 @@ namespace DigitalData.UserManager.Application.Services
|
||||
|
||||
return gous.Any() ? Result.Success() : Result.Fail();
|
||||
}
|
||||
|
||||
public async Task<DataResult<IEnumerable<GroupOfUserReadDto>>> ReadByUsernameAsync(string username)
|
||||
{
|
||||
var groups = await _repository.ReadByUsernameAsync(username);
|
||||
var groupDtos = _mapper.MapOrThrow<IEnumerable<GroupOfUserReadDto>>(groups);
|
||||
return Result.Success(groupDtos);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -26,5 +26,12 @@ namespace DigitalData.UserManager.Application.Services
|
||||
|
||||
return Result.Success();
|
||||
}
|
||||
|
||||
public async Task<DataResult<IEnumerable<ModuleOfUserReadDto>>> ReadByUserAsync(string username)
|
||||
{
|
||||
var mous = await _repository.ReadByUserAsync(username: username);
|
||||
var mous_dtos = _mapper.MapOrThrow<IEnumerable<ModuleOfUserReadDto>>(mous);
|
||||
return Result.Success(mous_dtos);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -14,5 +14,7 @@ namespace DigitalData.UserManager.Infrastructure.Contracts
|
||||
Task<IEnumerable<GroupOfUser>> ReadAllAsyncWithUser();
|
||||
|
||||
Task<IEnumerable<GroupOfUser>> ReadAllAsyncWithGroupAndUser();
|
||||
|
||||
Task<IEnumerable<GroupOfUser>> ReadByUsernameAsync(string username);
|
||||
}
|
||||
}
|
||||
@@ -8,5 +8,7 @@ namespace DigitalData.UserManager.Infrastructure.Contracts
|
||||
IQueryable<ModuleOfUser> ReadByModuleId(int moduleId);
|
||||
|
||||
Task<IEnumerable<ModuleOfUser>> ReadByModelUserIdAsync(int moduleId, int userId);
|
||||
|
||||
Task<IEnumerable<ModuleOfUser>> ReadByUserAsync(string username);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,20 +12,28 @@ namespace DigitalData.UserManager.Infrastructure.Repositories
|
||||
{
|
||||
}
|
||||
|
||||
//TODO: making it public and having it in the interface is against Clean Architecture. Make it private
|
||||
public IQueryable<GroupOfUser> ReadByGroupId(int groupId)
|
||||
{
|
||||
return _dbSet.Where<GroupOfUser>(mou => mou.GroupId == groupId);
|
||||
return _dbSet.Where(mou => mou.GroupId == groupId);
|
||||
}
|
||||
|
||||
private IQueryable<GroupOfUser> ReadByUsername(string userName)
|
||||
{
|
||||
return _dbSet.Where(gou => gou.User!.Username == userName).Include(gou => gou.Group);
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<GroupOfUser>> ReadByGroupUserIdAsync(int groupId, int userId)
|
||||
{
|
||||
return await _dbSet.Where<GroupOfUser>(gou => gou.GroupId == groupId && gou.UserId == userId).ToListAsync();
|
||||
return await _dbSet.Where(gou => gou.GroupId == groupId && gou.UserId == userId).ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<GroupOfUser>> ReadAllAsyncWithGroup() => await _dbSet.Include(gou => gou.Group).ToListAsync();
|
||||
|
||||
public async Task<IEnumerable<GroupOfUser>> ReadAllAsyncWithUser() => await _dbSet.Include(gou => gou.User).ToListAsync();
|
||||
|
||||
public async Task<IEnumerable<GroupOfUser>> ReadAllAsyncWithGroupAndUser() => await _dbSet.Include(gou => gou.Group).Include(gou => gou.User).ToListAsync();
|
||||
public async Task<IEnumerable<GroupOfUser>> ReadAllAsyncWithGroupAndUser() => await _dbSet.Include(gou => gou.Group).Include(gou => gou.User).ToListAsync();
|
||||
|
||||
public async Task<IEnumerable<GroupOfUser>> ReadByUsernameAsync(string username) => await ReadByUsername(username).ToListAsync();
|
||||
}
|
||||
}
|
||||
@@ -12,14 +12,21 @@ namespace DigitalData.UserManager.Infrastructure.Repositories
|
||||
{
|
||||
}
|
||||
|
||||
private IQueryable<ModuleOfUser> ReadByUser(string username)
|
||||
{
|
||||
return _dbSet.Where(mou => mou.User!.Username == username).Include(mou => mou.Module);
|
||||
}
|
||||
|
||||
public IQueryable<ModuleOfUser> ReadByModuleId(int moduleId)
|
||||
{
|
||||
return _dbSet.Where<ModuleOfUser>(mou => mou.ModuleId == moduleId);
|
||||
return _dbSet.Where(mou => mou.ModuleId == moduleId);
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<ModuleOfUser>> ReadByModelUserIdAsync(int moduleId, int userId)
|
||||
{
|
||||
return await _dbSet.Where<ModuleOfUser>(mou => mou.ModuleId == moduleId && mou.UserId == userId).ToListAsync();
|
||||
return await _dbSet.Where(mou => mou.ModuleId == moduleId && mou.UserId == userId).ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<ModuleOfUser>> ReadByUserAsync(string username) => await ReadByUser(username).ToListAsync();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user