refactor(user-representation.component): Aktualisiert, um als unbegrenzt zu speichern.

This commit is contained in:
Developer 02 2024-11-11 14:09:10 +01:00
parent 7e05123fbf
commit ff6ebf300c
4 changed files with 11 additions and 14 deletions

View File

@ -71,18 +71,20 @@ export class RepCreateFormComponent implements OnInit {
const validFrom = this.range.value.start; const validFrom = this.range.value.start;
const validTo = this.range.value.end; const validTo = this.range.value.end;
if (!validFrom || !validTo) { if ((!validFrom || !validTo) && !this.termless) {
Swal.fire({ Swal.fire({
icon: "error", icon: "error",
title: "Oops...", title: "Oops...",
text: "Bitte geben Sie einen gültigen Datumsbereich ein!", text: "Bitte geben Sie einen gültigen Datumsbereich ein oder wählen Sie unbefristet!",
}); });
return; return;
} }
if (!this.termless) {
this.userRep.validFrom = validFrom!; this.userRep.validFrom = validFrom!;
this.userRep.validTo = validTo!; this.userRep.validTo = validTo!;
}
this.userRepService.create(this.userRep).subscribe({ this.userRepService.create(this.userRep).subscribe({
next: (res) => { next: (res) => {

View File

@ -103,9 +103,7 @@ export class UserRepresentationComponent extends BasePageComponent implements Af
var newUserRep: UserRep = { var newUserRep: UserRep = {
userId: this.slUserId, userId: this.slUserId,
groupId: this.slGroupId, groupId: this.slGroupId,
repUserId: this.slRepUserId, repUserId: this.slRepUserId
validFrom: new Date(),
validTo: new Date(new Date().setDate(new Date().getDate() + 7))
} }
this.openCreateSheet(newUserRep, res => { this.openCreateSheet(newUserRep, res => {

View File

@ -32,6 +32,5 @@ namespace DigitalData.UserManager.Application.Services
: (createDto.ValidFrom > createDto.ValidTo) : (createDto.ValidFrom > createDto.ValidTo)
? Result.Fail<int>().Notice(LogLevel.None, Flag.DataIntegrityIssue, _localizer[Key.InvalidDateRange]) ? Result.Fail<int>().Notice(LogLevel.None, Flag.DataIntegrityIssue, _localizer[Key.InvalidDateRange])
: await base.CreateAsync(createDto); : await base.CreateAsync(createDto);
} }
} }

View File

@ -18,13 +18,11 @@ namespace DigitalData.UserManager.Domain.Entities
[Column("REPR_USER")] [Column("REPR_USER")]
public int? RepUserId { get; set; } public int? RepUserId { get; set; }
[Required]
[Column("VALID_FROM")] [Column("VALID_FROM")]
public required DateTime? ValidFrom { get; set; } public DateTime? ValidFrom { get; set; }
[Required]
[Column("VALID_TO")] [Column("VALID_TO")]
public required DateTime? ValidTo { get; set; } public DateTime? ValidTo { get; set; }
[ForeignKey("UserId")] [ForeignKey("UserId")]
public virtual User? User { get; set; } public virtual User? User { get; set; }