diff --git a/DigitalData.UserManager.API/ClientApp/user_manager_ui/src/app/components/forms/rep-create-form/rep-create-form.component.ts b/DigitalData.UserManager.API/ClientApp/user_manager_ui/src/app/components/forms/rep-create-form/rep-create-form.component.ts index d46ba3b..1e1c826 100644 --- a/DigitalData.UserManager.API/ClientApp/user_manager_ui/src/app/components/forms/rep-create-form/rep-create-form.component.ts +++ b/DigitalData.UserManager.API/ClientApp/user_manager_ui/src/app/components/forms/rep-create-form/rep-create-form.component.ts @@ -71,18 +71,20 @@ export class RepCreateFormComponent implements OnInit { const validFrom = this.range.value.start; const validTo = this.range.value.end; - if (!validFrom || !validTo) { + if ((!validFrom || !validTo) && !this.termless) { Swal.fire({ icon: "error", 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; } - this.userRep.validFrom = validFrom!; - this.userRep.validTo = validTo!; + if (!this.termless) { + this.userRep.validFrom = validFrom!; + this.userRep.validTo = validTo!; + } this.userRepService.create(this.userRep).subscribe({ next: (res) => { @@ -94,4 +96,4 @@ export class RepCreateFormComponent implements OnInit { } }); } -} \ No newline at end of file +} diff --git a/DigitalData.UserManager.API/ClientApp/user_manager_ui/src/app/pages/user-representation/user-representation.component.ts b/DigitalData.UserManager.API/ClientApp/user_manager_ui/src/app/pages/user-representation/user-representation.component.ts index 3d02507..830071c 100644 --- a/DigitalData.UserManager.API/ClientApp/user_manager_ui/src/app/pages/user-representation/user-representation.component.ts +++ b/DigitalData.UserManager.API/ClientApp/user_manager_ui/src/app/pages/user-representation/user-representation.component.ts @@ -103,9 +103,7 @@ export class UserRepresentationComponent extends BasePageComponent implements Af var newUserRep: UserRep = { userId: this.slUserId, groupId: this.slGroupId, - repUserId: this.slRepUserId, - validFrom: new Date(), - validTo: new Date(new Date().setDate(new Date().getDate() + 7)) + repUserId: this.slRepUserId } this.openCreateSheet(newUserRep, res => { diff --git a/DigitalData.UserManager.Application/Services/UserRepService.cs b/DigitalData.UserManager.Application/Services/UserRepService.cs index 348b7c9..e93d3fd 100644 --- a/DigitalData.UserManager.Application/Services/UserRepService.cs +++ b/DigitalData.UserManager.Application/Services/UserRepService.cs @@ -31,7 +31,6 @@ namespace DigitalData.UserManager.Application.Services //date range control : (createDto.ValidFrom > createDto.ValidTo) ? Result.Fail().Notice(LogLevel.None, Flag.DataIntegrityIssue, _localizer[Key.InvalidDateRange]) - : await base.CreateAsync(createDto); - + : await base.CreateAsync(createDto); } } \ No newline at end of file diff --git a/DigitalData.UserManager.Domain/Entities/UserRep.cs b/DigitalData.UserManager.Domain/Entities/UserRep.cs index a09a032..9a4051d 100644 --- a/DigitalData.UserManager.Domain/Entities/UserRep.cs +++ b/DigitalData.UserManager.Domain/Entities/UserRep.cs @@ -18,13 +18,11 @@ namespace DigitalData.UserManager.Domain.Entities [Column("REPR_USER")] public int? RepUserId { get; set; } - [Required] [Column("VALID_FROM")] - public required DateTime? ValidFrom { get; set; } + public DateTime? ValidFrom { get; set; } - [Required] [Column("VALID_TO")] - public required DateTime? ValidTo { get; set; } + public DateTime? ValidTo { get; set; } [ForeignKey("UserId")] public virtual User? User { get; set; }