Compare commits

...

10 Commits

Author SHA1 Message Date
Developer 02
968ff8349f feat(UserRep): Required-Attribut für ValidFrom und ValidTo hinzugefügt. 2024-11-06 17:13:09 +01:00
Developer 02
770921011a feat: Füge die Spalten ValidFrom und ValidTo zur UserRep-DTO hinzu. 2024-11-06 17:11:38 +01:00
Developer 02
a9bc4f90ac feat: Füge die Spalten ValidFrom und ValidTo zur UserRep-Entität hinzu. 2024-11-06 16:32:47 +01:00
Developer 02
6e5ba82869 fix(user-representation): UserRep.addedWho nullable machen, um die Annahme des aktuellen Benutzers durch die API zu ermöglichen 2024-11-06 16:26:21 +01:00
Developer 02
fb3dedadc5 refactor: Ersetze fetchData-Aufrufe durch fetchByUser- und fetchByGroup-Methoden in UserRepresentationComponent, um Fehler zu vermeiden. 2024-11-06 15:46:27 +01:00
Developer 02
8cf2183cd6 refactor(user-representation): Umbenennung von 'slUserRepId' in 'slRepId' 2024-11-06 15:37:48 +01:00
Developer 02
881d2ccac8 refactor(user-representation): Umbenennung von 'userRepOnSelectedRows' in 'repOnSelectedRows' 2024-11-06 15:34:51 +01:00
Developer 02
deacd1a8c6 fix: Parameter in den ReadAllAsync-Methoden in UserRepController und UserRepService explizit benennen 2024-11-06 14:57:14 +01:00
Developer 02
616862391e feat: fetchByUser und fetchByGroup Methoden in UserRepTableComponent zur gezielten Datenabfrage hinzugefügt 2024-11-06 11:15:21 +01:00
Developer 02
296f29cf82 refactor: redundante Funktion entfernen und Logik zur Verarbeitung ausgewählter Zeilen in UserRepresentationComponent konsolidieren 2024-11-06 10:52:19 +01:00
10 changed files with 64 additions and 52 deletions

View File

@@ -31,4 +31,12 @@ export class UserRepTableComponent extends BaseTableComponent<UserRep, UserRepSe
error: (error: any) => { }
});
}
public fetchByUser(id: number): void {
this.fetchData(id, undefined);
}
public fetchByGroup(id: number): void {
this.fetchData(undefined, id);
}
}

View File

@@ -64,7 +64,7 @@ export interface UserRep {
userId?: number,
repGroupId?: number,
groupId?: number,
addedWho: string,
addedWho?: string,
repUser?: User
user?: User,
repGroup?: Group,

View File

@@ -27,7 +27,7 @@
<div class="col-3">
<mat-tab-group>
<mat-tab label="{{useRepLabel}}">
<app-user-rep-table #userReps [initData]="initWithoutData" [onSelectedRows]="userRepOnSelectedRows"></app-user-rep-table>
<app-user-rep-table #userReps [initData]="initWithoutData" [onSelectedRows]="repOnSelectedRows"></app-user-rep-table>
</mat-tab>
</mat-tab-group>
</div>

View File

@@ -26,7 +26,7 @@ export class UserRepresentationComponent extends BasePageComponent implements Af
slGroupId?: number;
slRepUserId?: number;
slRepGroupId?: number;
slUserRepId?: number;
slRepId?: number;
initWithoutData = () => { }
@@ -59,31 +59,24 @@ export class UserRepresentationComponent extends BasePageComponent implements Af
@ViewChild("repGroups") repGroups!: GroupTableComponent;
@ViewChild("userReps") userReps!: UserRepTableComponent;
userGroupOnSelectedRows = (rows: GuiSelectedRow[], isUser: boolean = true) => {
userOnSelectedRows = (rows: GuiSelectedRow[]) => {
if (rows.length > 0) {
if (isUser) {
this.useRepLabel = `Vertretungen von ${rows[0].source?.username}`
this.users.safelyUnselectAll();
this.userReps.fetchData(rows[0].source?.id)
this.slGroupId = undefined;
this.slUserId = rows[0].source?.id
}
else {
this.useRepLabel = `Vertretungen von ${rows[0].source?.name}`
this.groups.safelyUnselectAll();
this.userReps.fetchData(undefined, rows[0].source?.id)
this.slUserId = undefined;
this.slGroupId = rows[0].source?.id
}
this.useRepLabel = `Vertretungen von ${rows[0].source?.username}`
this.users.safelyUnselectAll();
this.userReps.fetchByUser(rows[0].source?.id);
this.slGroupId = undefined;
this.slUserId = rows[0].source?.id
}
}
userOnSelectedRows = (rows: GuiSelectedRow[]) => {
this.userGroupOnSelectedRows(rows, true);
}
groupOnSelectedRows = (rows: GuiSelectedRow[]) => {
this.userGroupOnSelectedRows(rows, false);
if (rows.length > 0) {
this.useRepLabel = `Vertretungen von ${rows[0].source?.name}`
this.groups.safelyUnselectAll();
this.userReps.fetchByGroup(rows[0].source?.id);
this.slUserId = undefined;
this.slGroupId = rows[0].source?.id
}
}
repUserOnSelectedRows = (rows: GuiSelectedRow[]) => {
@@ -107,7 +100,6 @@ export class UserRepresentationComponent extends BasePageComponent implements Af
userId: this.slUserId,
groupId: this.slGroupId,
repUserId: this.slRepUserId,
addedWho: 'DEFAULT'
}
this.userRepService.create(newUserRep).subscribe({
next: (response) => {
@@ -115,10 +107,10 @@ export class UserRepresentationComponent extends BasePageComponent implements Af
this.repUsers.safelyUnselectAll()
this.repGroups.safelyUnselectAll()
if (this.slUserId != undefined)
this.userReps.fetchData(this.slUserId)
if (this.slGroupId != undefined)
this.userReps.fetchData(this.slGroupId)
if (this.slUserId)
this.userReps.fetchByUser(this.slUserId)
if (this.slGroupId)
this.userReps.fetchByGroup(this.slGroupId)
},
error: (error) => {
Swal.fire({
@@ -158,17 +150,16 @@ export class UserRepresentationComponent extends BasePageComponent implements Af
userId: this.slUserId,
groupId: this.slGroupId,
repGroupId: this.slRepGroupId,
addedWho: 'DEFAULT'
}
this.userRepService.create(newUserRep).subscribe({
next: (res) => {
this.slRepGroupId = undefined;
this.repUsers.safelyUnselectAll()
this.groups.safelyUnselectAll()
if (this.slUserId != undefined)
this.userReps.fetchData(this.slUserId)
if (this.slGroupId != undefined)
this.userReps.fetchData(undefined, this.slGroupId)
if (this.slUserId)
this.userReps.fetchByUser(this.slUserId)
if (this.slGroupId)
this.userReps.fetchByGroup(this.slGroupId)
},
error: (error) => {
Swal.fire({
@@ -187,11 +178,11 @@ export class UserRepresentationComponent extends BasePageComponent implements Af
}
}
userRepOnSelectedRows = (rows: GuiSelectedRow[]) => {
if (rows.length == 0 && this.slUserRepId) {
this.userRepService.delete(this.slUserRepId).subscribe({
repOnSelectedRows = (rows: GuiSelectedRow[]) => {
if (rows.length == 0 && this.slRepId) {
this.userRepService.delete(this.slRepId).subscribe({
next: (res) => {
this.slUserRepId = undefined;
this.slRepId = undefined;
this.userReps.safelyUnselectAll();
if (this.slUserId != undefined)
this.userReps.fetchData(this.slUserId)
@@ -199,7 +190,7 @@ export class UserRepresentationComponent extends BasePageComponent implements Af
this.userReps.fetchData(undefined, this.slGroupId)
},
error: (err) => {
this.slUserRepId = undefined;
this.slRepId = undefined;
this.repUsers.safelyUnselectAll()
Swal.fire({
icon: "error",
@@ -210,7 +201,7 @@ export class UserRepresentationComponent extends BasePageComponent implements Af
})
}
else if (rows.length > 0) {
this.slUserRepId = rows[0].source?.id;
this.slRepId = rows[0].source?.id;
}
}
}
}

View File

@@ -19,18 +19,18 @@ namespace DigitalData.UserManager.API.Controllers
{
return base.GetAll();
}
[HttpGet]
public async Task<IActionResult> GetAll(bool withUser = false, bool withRepGroup = false, bool withGroup = false, bool withRepUser = false, int? userId = null, int? groupId = null)
{
try
{
return await _service.ReadAllAsync(withUser, withRepGroup, withGroup, withRepUser, userId, groupId).ThenAsync(Ok, IActionResult (m, n) =>
return await _service.ReadAllAsync(withUser: withUser, withRepGroup: withRepGroup, withGroup: withGroup, withRepUser: withRepUser,
userId: userId, groupId: groupId).ThenAsync(Ok, IActionResult (m, n) =>
{
_logger.LogNotice(n);
return NotFound();
});
});
}
catch (Exception ex)
{

View File

@@ -6,6 +6,8 @@ namespace DigitalData.UserManager.Application.DTOs.UserRep
int? UserId,
int? RepGroupId,
int? GroupId,
int? RepUserId
int? RepUserId,
DateTime? ValidFrom,
DateTime? ValidTo
) : BaseCreateDto();
}

View File

@@ -9,9 +9,11 @@ namespace DigitalData.UserManager.Application.DTOs.UserRep
int? UserId,
int? GroupId,
int? RepUserId,
int? RepGroupId,
int? RepGroupId,
DateTime ValidFrom,
DateTime ValidTo,
string AddedWho,
string? ChangedWho,
string? ChangedWho,
UserReadDto? User,
GroupReadDto? RepGroup,
GroupReadDto? Group,

View File

@@ -6,6 +6,8 @@ namespace DigitalData.UserManager.Application.DTOs.UserRep
int? UserId,
int? RepGroupId,
int? GroupId,
int? RepUserId
int? RepUserId,
DateTime? ValidFrom,
DateTime? ValidTo
) : BaseUpdateDto();
}

View File

@@ -1,5 +1,4 @@
using AutoMapper;
using DigitalData.Core.Application;
using DigitalData.Core.DTO;
using DigitalData.UserManager.Application.Contracts;
using DigitalData.UserManager.Application.DTOs.UserRep;
@@ -17,7 +16,7 @@ namespace DigitalData.UserManager.Application.Services
public async Task<DataResult<IEnumerable<UserRepReadDto>>> ReadAllAsync(bool withUser = false, bool withRepGroup = false, bool withGroup = false, bool withRepUser = false, int? userId = null, int? groupId = null)
{
var urs = await _repository.ReadAllAsync(withUser, withRepGroup, withGroup, withRepUser, userId, groupId);
var urs = await _repository.ReadAllAsync(withUser: withUser, withRepGroup: withRepGroup, withGroup: withGroup, withRepUser: withRepUser, userId: userId, groupId: groupId);
var urReadDTOs = _mapper.Map<IEnumerable<UserRepReadDto>>(urs);
return Result.Success(urReadDTOs);
}

View File

@@ -1,5 +1,5 @@
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace DigitalData.UserManager.Domain.Entities
{
@@ -18,6 +18,14 @@ namespace DigitalData.UserManager.Domain.Entities
[Column("REPR_USER")]
public int? RepUserId { get; set; }
[Required]
[Column("VALID_FROM")]
public required DateTime ValidFrom { get; set; }
[Required]
[Column("VALID_TO")]
public required DateTime ValidTo { get; set; }
[ForeignKey("UserId")]
public virtual User? User { get; set; }