public void HasGetSet()
 {
     const string value = "text";
     var entity = new InstitutionalAgreementContact { Type = value };
     entity.ShouldNotBeNull();
     entity.Type.ShouldEqual(value);
 }
 public void HasGetSet()
 {
     var value = new Person();
     var entity = new InstitutionalAgreementContact { Person = value };
     entity.ShouldNotBeNull();
     entity.Person.ShouldEqual(value);
 }
示例#3
0
            public void HasGetSet()
            {
                var value  = new Person();
                var entity = new InstitutionalAgreementContact {
                    Person = value
                };

                entity.ShouldNotBeNull();
                entity.Person.ShouldEqual(value);
            }
示例#4
0
            public void HasGetSet()
            {
                const string value  = "text";
                var          entity = new InstitutionalAgreementContact {
                    Type = value
                };

                entity.ShouldNotBeNull();
                entity.Type.ShouldEqual(value);
            }
        public void Handle(AddContactToAgreementCommand command)
        {
            if (command == null)
            {
                throw new ArgumentNullException("command");
            }

            var agreement = command.Agreement ??
                            _entities.Get <InstitutionalAgreement>()
                            .EagerLoad(_entities, new Expression <Func <InstitutionalAgreement, object> >[]
            {
                r => r.Contacts.Select(c => c.Person),
            })
                            .By(command.AgreementEntityId);

            if (command.EntityId != Guid.Empty)
            {
                var entity = agreement.Contacts.SingleOrDefault(
                    e => e.EntityId == command.EntityId);
                if (entity != null)
                {
                    return;
                }
            }

            var contact = new InstitutionalAgreementContact
            {
                Agreement = agreement,
                Type      = command.ContactType,
            };

            if (command.PersonEntityId != Guid.Empty)
            {
                contact.Person = _entities.Get <Person>().By(command.PersonEntityId);
            }
            else
            {
                contact.Person = new Person
                {
                    Salutation  = command.PersonSalutation,
                    FirstName   = command.PersonFirstName,
                    MiddleName  = command.PersonMiddleName,
                    LastName    = command.PersonLastName,
                    Suffix      = command.PersonSuffix,
                    DisplayName = command.PersonDisplayName,
                    Emails      = (!string.IsNullOrWhiteSpace(command.PersonDefaultEmail))
                        ? new Collection <EmailAddress>
                    {
                        new EmailAddress
                        {
                            Value     = command.PersonDefaultEmail,
                            IsDefault = true,
                        }
                    }
                        : new Collection <EmailAddress>(),
                }
            };

            _entities.Create(contact);
            command.IsNewlyAdded = true;
        }
    }