public async Task <IActionResult> GetBuildingApartments(int buildingId) { var ownerTenats = await buildingManager.GetAllCurrentOwnerTenants(buildingId); var apartments = await buildingManager.GetApartmentsOfBuilding(buildingId); var apartmentModels = apartments.Select(a => new ApartmentOwnerTenantResponse { Apartment = a, Owner = ownerTenats.FirstOrDefault(c => c.IsOwner && c.ApartmentId == a.ApartmentId), Tenant = ownerTenats.FirstOrDefault(c => !c.IsOwner && c.ApartmentId == a.ApartmentId), }); return(Ok(apartmentModels.WrapResponse(Request.Path))); }