Ejemplo n.º 1
0
        public override Data.Model.User Save(Data.Model.User user)
        {
            var result = Validator.Validate(user);

            if (result.IsValid)
            {
                var entity = Persistor.Save(user);
                Persistor.Commit();
                return(entity);
            }
            var properties = result.Errors.Select(e => e.PropertyName).ToArray();

            throw new ArgumentException("One or more properties a required",
                                        String.Join(", ", properties.ToArray()));
        }
        protected override async Task HandleCore(UpsertRegisteredUserCommand message)
        {
            var validationResult = _validator.Validate(message);

            if (!validationResult.IsValid())
            {
                throw new InvalidRequestException(validationResult.ValidationDictionary);
            }

            await _userRepository.Upsert(new User
            {
                UserRef   = message.UserRef,
                Email     = message.EmailAddress,
                FirstName = message.FirstName,
                LastName  = message.LastName
            });
        }
Ejemplo n.º 3
0
        protected override async Task HandleCore(ReviewApprenticeshipUpdateCommand command)
        {
            var validationResult = _validator.Validate(command);

            if (!validationResult.IsValid())
            {
                throw new ValidationException("Validation failed");
            }

            await _commitmentsApi.PatchApprenticeshipUpdate(command.AccountId, command.ApprenticeshipId,
                                                            new ApprenticeshipUpdateSubmission
            {
                UpdateStatus      = command.IsApproved ? ApprenticeshipUpdateStatus.Approved : ApprenticeshipUpdateStatus.Rejected,
                UserId            = command.UserId,
                LastUpdatedByInfo = new LastUpdateInfo {
                    EmailAddress = command.UserEmailAddress, Name = command.UserDisplayName
                }
            });
        }
        protected override async Task HandleCore(UndoApprenticeshipUpdateCommand command)
        {
            var validationResult = _validator.Validate(command);

            if (!validationResult.IsValid())
            {
                throw new ValidationException(validationResult.ValidationDictionary.FirstOrDefault().Value);
            }

            var submission = new ApprenticeshipUpdateSubmission
            {
                UpdateStatus      = ApprenticeshipUpdateStatus.Deleted,
                UserId            = command.UserId,
                LastUpdatedByInfo = new LastUpdateInfo {
                    EmailAddress = command.UserEmailAddress, Name = command.UserDisplayName
                }
            };

            await _commitmentsApi.PatchApprenticeshipUpdate(command.AccountId, command.ApprenticeshipId, submission);
        }