// Get One housing unit with Provider // DEFAULT // RETURNS ONE HOUSING UNIT BY ID WITH: Address, and Provider with Contact public HousingUnitProviderMapper GetHousingUnitWithProvider(int housingUnitId) { var content = db.HousingUnits.Where(j => j.housingUnitId == housingUnitId).FirstOrDefault(); if (content == null) { return(null); } else { AddressesHelper address = new AddressesHelper(); ProvidersHelper provider = new ProvidersHelper(); HousingUnitProviderMapper housingUnit = new HousingUnitProviderMapper() { HousingUnitId = content.housingUnitId, ProviderId = content.providerId ?? 0, AddressId = content.addressId ?? 0, HousingSignature = content.housingSignature, Capacity = content.capacity, Address = address.GetAddress(content.addressId ?? 0), Provider = provider.GetProviderWithContact(housingUnitId) }; return(housingUnit); } }
// Get All housing units with Provider // DEFAULT // RETURNS ALL THE HOUSING UNITS WITH: Address, and Provider with Contact public IEnumerable <HousingUnitProviderMapper> GetHousingUnitsWithProvider() { var content = db.HousingUnits.Where(j => j.housingUnitId != 0).ToList(); if (content.Count() == 0) { return(null); } else { List <HousingUnitProviderMapper> housingUnits = new List <HousingUnitProviderMapper>(); AddressesHelper address = new AddressesHelper(); ProvidersHelper provider = new ProvidersHelper(); foreach (var item in content) { HousingUnitProviderMapper housingUnit = new HousingUnitProviderMapper() { HousingUnitId = item.housingUnitId, ProviderId = item.providerId ?? 0, AddressId = item.addressId ?? 0, HousingSignature = item.housingSignature, Capacity = item.capacity, Address = address.GetAddress(item.addressId ?? 0), Provider = provider.GetProviderWithContact(item.providerId ?? 0) }; housingUnits.Add(housingUnit); } return(housingUnits); } }