Beispiel #1
0
        public DomainErrorList UpdatePrimaryEmail(string email)
        {
            // Validate

            var errors = new DomainErrorList();

            if (email.IsNullOrWhiteSpace())
            {
                errors.Add("Email address cannot be empty.");
            }

            if (errors)
            {
                return(errors);
            }

            // Execute

            _primaryEmail = email.Trim();

            // Notify

            _domainEventsQueue.Add(
                new PersonPrimaryEmailUpdatedDomainEvent(
                    Guid.NewGuid(),
                    Id,
                    Name,
                    _primaryEmail));

            return(errors);
        }
        public static CommonResult CommonResultFromDomainErrorList(this DomainErrorList domainErrorList,
                                                                   IRequest <CommonResult> request, ILogger logger)
        {
            ResultErrorCollection errorList = new ResultErrorCollection();

            foreach (string error in domainErrorList)
            {
                errorList.Add("", error);
            }

            return
                (new CommonResult(
                     messageId: ((IMessage)request).MessageId,
                     outcome: Outcome.DomainValidationFailure,
                     flashMessage: "A domain validation error occured handling request " + request.GetType() +
                     ", CorrelationID: " + CorrelationId,
                     errors: errorList));
        }
Beispiel #3
0
        // Behaviors

        public DomainErrorList UpdateName(string firstName, string lastName)
        {
            // Validate

            var errors = new DomainErrorList();

            if (firstName.IsNullOrWhiteSpace())
            {
                errors.Add("FirstName cannot be empty.");
            }

            if (lastName.IsNullOrWhiteSpace())
            {
                errors.Add("LastName cannot be empty");
            }

            if (errors)
            {
                return(errors);
            }

            // Execute

            _firstName = firstName.Trim();
            _lastName  = lastName.Trim();

            // Notify

            _domainEventsQueue.Add(
                new PersonNameUpdatedDomainEvent(
                    Guid.NewGuid(),
                    Id,
                    Name,
                    FirstName,
                    LastName));

            return(errors);
        }