Exemple #1
0
        public void InsertHouse(DTOHouse dto)
        {
            var house = new House
            {
                Number = dto.Number,
                Phone  = dto.Phone
            };

            _houseRepository.Insert(house);

            if (dto.Residents != null && dto.Residents.Count > 0)
            {
                foreach (var resident in dto.Residents)
                {
                    var person = new Person()
                    {
                        Cpf         = resident.Cpf,
                        DateOfBirth = resident.DateOfBirth,
                        Name        = resident.Name,
                        Nickname    = resident.Nickname
                    };
                    _personRepository.Insert(person);

                    if (resident.Contact != null)
                    {
                        var contact = new Contact
                        {
                            PersonId   = person.Id,
                            Email      = resident.Contact.Email,
                            Cellphone1 = resident.Contact.Cellphone1,
                            Cellphone2 = resident.Contact.Cellphone2
                        };
                        _contactRepository.Insert(contact);
                    }

                    var family = new Family()
                    {
                        HouseId              = house.Id,
                        PersonId             = person.Id,
                        FamilyRelationshipId = (int)resident.FamilyRelationshipId
                    };
                    _familyRepository.Insert(family);
                }
            }
        }
Exemple #2
0
 public ActionResult CreateHouse(DTOHouse dto)
 {
     return(Ok());
 }