//update property and its dependencies
        public void UpdateProperty(PropertyDTO dto, int id)
        {
            var property = _mapper.Map <Property>(dto);

            var address = _context.Address.First(x => x.IdProperty == property.Id);

            address.State    = property.Address.State;
            address.Zip      = property.Address.Zip;
            address.Address1 = property.Address.Address1;
            address.City     = property.Address.City;


            var financial = _context.Financial.First(x => x.IdProperty == property.Id);

            financial.ListPrice   = property.Financial.ListPrice;
            financial.MonthlyRent = property.Financial.MonthlyRent;

            var physical = _context.Physical.First(x => x.IdProperty == property.Id);

            physical.YearBuilt = property.Physical.YearBuilt;

            _context.SaveChanges();
        }
示例#2
0
        public Object SaveProperty([FromBody] Property property)
        {
            try
            {
                db.Property.Add(property);
                db.SaveChanges();
            }
            catch (Exception ex)
            {
                return(ex.Message);
            }

            return(property);
        }