Esempio n. 1
0
        public Result <Nothing, Error> RecordResignation(RecordResignation.Command command, ApplicationUser recordingCoordinator, Instant now)
        {
            Guard.Against.Null(command, nameof(command));
            Guard.Against.Null(recordingCoordinator, nameof(recordingCoordinator));
            ValidateIdMatchOrThrow(command.EnrollmentId);

            return
                (Validate(new RecordResignation.Validator(), command)
                 .Ensure(
                     _ => this.IsNew == false,
                     new Error.ResourceNotFound(CommonErrorMessages.CandidateNotFound))
                 .Ensure(
                     _ => {
                if (command.ResignationType == Recruitment.Enrollments.RecordResignation.ResignationType.Temporary && command.ResumeDate.HasValue)
                {
                    return command.ResumeDate.Value >= now.InMainTimezone().Date;
                }
                else
                {
                    return true;
                }
            },
                     new Error.DomainError(RecordResignation_Messages.ResumeDateCannotBeEarlierThanToday))
                 .TapIf(
                     command.ResignationType == Recruitment.Enrollments.RecordResignation.ResignationType.Permanent,
                     () => Emit(new CandidateResignedPermanently(
                                    recordingCoordinatorID: recordingCoordinator.Id,
                                    communicationChannel: command.CommunicationChannel,
                                    resignationReason: command.ResignationReason ?? string.Empty,
                                    additionalNotes: command.AdditionalNotes ?? string.Empty)))
                 .TapIf(
                     command.ResignationType == Recruitment.Enrollments.RecordResignation.ResignationType.Temporary,
                     () => Emit(new CandidateResignedTemporarily(
                                    recordingCoordinatorID: recordingCoordinator.Id,
                                    communicationChannel: command.CommunicationChannel,
                                    resignationReason: command.ResignationReason ?? string.Empty,
                                    additionalNotes: command.AdditionalNotes ?? string.Empty,
                                    resumeDate: command.ResumeDate))));
        }
Esempio n. 2
0
 public bool HasResignedEffectively(Instant time) => HasResignedPermanently || (HasResignedTemporarily && (ResumeDate == null || ResumeDate.Value >= time.InMainTimezone().Date));