public async Task <IActionResult> GetProperty(int id) { /* Get the property from the asset repo by its id*/ var propertry = await _repo.GetCompaniesPropertyAsync(id); /* Refrences to related entities*/ var companyCode = propertry.CompanyId.GetValueOrDefault(); propertry.Company = _repo.GetCompany(companyCode); var ownerCode = propertry.OwnerId.GetValueOrDefault(); propertry.Owner = _repo.GetOwner(ownerCode); var beneficiaryCode = propertry.BeneficiaryId.GetValueOrDefault(); propertry.Beneficiary = _repo.GetBeneficiary(beneficiaryCode); var userCode = propertry.UserId.GetValueOrDefault(); propertry.User = _repo.GetUserSync(userCode); var provinceCode = propertry.ProvinceId.GetValueOrDefault(); propertry.Province = _repo.GetProvince(provinceCode); var cityCode = propertry.CityId.GetValueOrDefault(); propertry.City = _repo.GetCity(cityCode); var ownershipDocumentTypeCode = propertry.OwnershipDocumentTypeId.GetValueOrDefault(); propertry.OwnershipDocumentType = _repo.GetOwnershipDocumentType(ownershipDocumentTypeCode); var mapFormatCode = propertry.MapFormatId.GetValueOrDefault(); propertry.MapFormat = _repo.GetMapFormat(mapFormatCode); var mapCoordinatesAccuracyCode = propertry.MapCoordinatesAccuracyId.GetValueOrDefault(); propertry.MapCoordinatesAccuracy = _repo.GetMapCoordinatesAccuracy(mapCoordinatesAccuracyCode); var buildingTypeCode = propertry.BuildingTypeId.GetValueOrDefault(); propertry.BuildingType = _repo.GetBuildingType(buildingTypeCode); /* Return the property*/ var propertyToReturn = _mapper.Map <PropertyToReturnDto>(propertry); return(Ok(propertyToReturn)); }