コード例 #1
0
        public void AddRelative(string personId, RelativeInputModel relativeInputModel)
        {
            Person person = this.GetPerson(personId);

            string relativeId = this.relativesService.Add(relativeInputModel);

            PersonRelative personRelative = new PersonRelative()
            {
                PersonId   = person.Id,
                RelativeId = relativeId
            };

            this.db.PersonRelatives.Add(personRelative);
            this.db.SaveChanges();
        }
コード例 #2
0
        public string Add(RelativeInputModel relativeInputModel)
        {
            Relative relative = new Relative()
            {
                RelativeType = relativeInputModel.RelativeType,
                FirstName    = relativeInputModel.FirstName,
                MiddleName   = relativeInputModel.MiddleName,
                LastName     = relativeInputModel.LastName
            };

            if (relativeInputModel.Address != null)
            {
                string  addressId = this.addressesService.Add(relativeInputModel.Address);
                Address address   = this.addressesService.GetAddress(addressId);
                relative.Addresses.Add(address);
            }

            if (relativeInputModel.Phone != null)
            {
                string phoneId = this.phonesService.Add(relativeInputModel.Phone);
                Phone  phone   = this.phonesService.GetPhone(phoneId);
                relative.Phones.Add(phone);
            }

            if (relativeInputModel.Email != null)
            {
                string       emailId = this.emailsService.Add(relativeInputModel.Email);
                EmailAddress email   = this.emailsService.GetEmail(emailId);
                relative.Emails.Add(email);
            }


            this.db.Relatives.Add(relative);
            this.db.SaveChanges();

            return(relative.Id);
        }