// Get All supply request by House Unit/tenat
        // DEFAULT
        // RETURNS ALL THE HOUSING UNITS WITH: Address, and Tenants with Supply Requests
        public IEnumerable <HousingUnitProviderTenantSupplyMapper> GetHousingUnitsSupplyRequest(int housingUnitId)
        {
            var content = db.HousingUnits.Where(j => j.housingUnitId == housingUnitId).ToList();

            if (content.Count() == 0)
            {
                return(null);
            }
            else
            {
                List <HousingUnitProviderTenantSupplyMapper> housingUnits = new List <HousingUnitProviderTenantSupplyMapper>();
                AddressesHelper address = new AddressesHelper();
                TenantsHelper   tenants = new TenantsHelper();
                foreach (var item in content)
                {
                    HousingUnitProviderTenantSupplyMapper housingUnit = new HousingUnitProviderTenantSupplyMapper
                    {
                        HousingUnitId    = item.housingUnitId,
                        ProviderId       = item.providerId ?? 0,
                        AddressId        = item.addressId ?? 0,
                        HousingSignature = item.housingSignature,
                        Capacity         = item.capacity,

                        Address = address.GetAddress(item.addressId ?? 0),
                        Tenants = tenants.GetTenantsWithSupplies(item.housingUnitId)
                    };
                    housingUnits.Add(housingUnit);
                }
                return(housingUnits);
            }
        }
        // Get All with Address
        // DEFAULT
        // RETURNS ALL THE HOUSING UNITS WITH: Address
        public IEnumerable <HousingUnitAddressMapper> GetHousingUnitsWithAddress()
        {
            var content = db.HousingUnits.ToList();

            if (content.Count() == 0)
            {
                return(null);
            }
            else
            {
                List <HousingUnitAddressMapper> housingUnits = new List <HousingUnitAddressMapper>();
                AddressesHelper address = new AddressesHelper();
                foreach (var item in content)
                {
                    HousingUnitAddressMapper housingUnit = new HousingUnitAddressMapper()
                    {
                        HousingUnitId    = item.housingUnitId,
                        ProviderId       = item.providerId ?? 0,
                        AddressId        = item.addressId ?? 0,
                        HousingSignature = item.housingSignature,
                        Capacity         = item.capacity,

                        Address = address.GetAddress(item.addressId ?? 0)
                    };
                    housingUnits.Add(housingUnit);
                }
                return(housingUnits);
            }
        }
        // Get One housing unit with Tenants
        // DEFAULT
        // RETURNS ONE HOUSING UNIT WITH: Tenants with Batch, Contact, Gender, and Car Relationship
        public HousingUnitTenantInfoMapper GetHousingUnitWithTenants(int housingUnitId)
        {
            var content = db.HousingUnits.Where(j => j.housingUnitId == housingUnitId).FirstOrDefault();

            if (content == null)
            {
                return(null);
            }
            else
            {
                AddressesHelper             address     = new AddressesHelper();
                TenantsHelper               tenants     = new TenantsHelper();
                HousingUnitTenantInfoMapper housingUnit = new HousingUnitTenantInfoMapper()
                {
                    HousingUnitId    = content.housingUnitId,
                    ProviderId       = content.providerId ?? 0,
                    AddressId        = content.addressId ?? 0,
                    HousingSignature = content.housingSignature,
                    Capacity         = content.capacity,

                    Address = address.GetAddress(content.addressId ?? 0),
                    Tenants = tenants.GetTenantsWithInfoByHousing(content.housingUnitId)
                };
                return(housingUnit);
            }
        }
        // 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 One with Address
        // DEAFULT
        // RETURNS ALL THE HOUSING UNITS BY ID WITH: Address
        public HousingUnitAddressMapper GetHousingUnitWithAddress(int housingUnitId)
        {
            var content = db.HousingUnits.FirstOrDefault(j => j.housingUnitId == housingUnitId);

            if (content == null)
            {
                return(null);
            }
            else
            {
                AddressesHelper          address     = new AddressesHelper();
                HousingUnitAddressMapper housingUnit = new HousingUnitAddressMapper()
                {
                    HousingUnitId    = content.housingUnitId,
                    ProviderId       = content.providerId ?? 0,
                    AddressId        = content.addressId ?? 0,
                    HousingSignature = content.housingSignature,
                    Capacity         = content.capacity,

                    Address = address.GetAddress(content.addressId ?? 0)
                };

                return(housingUnit);
            }
        }
        // Get All housing units with Tenants
        // DEFAULT
        // RETURNS ALL THE HOUSING UNITS WITH: Tenants with Batch, Contact, Gender, and Car Relationship
        public IEnumerable <HousingUnitAvailableMapper> GetHousingUnitsWithTenantsAvailable()
        {
            var content = db.HousingUnits.Where(j => j.housingUnitId != 0).ToList();

            if (content.Count() == 0)
            {
                return(null);
            }
            else
            {
                List <HousingUnitAvailableMapper> housingUnits = new List <HousingUnitAvailableMapper>();
                AddressesHelper address = new AddressesHelper();
                TenantsHelper   tenants = new TenantsHelper();
                foreach (var item in content)
                {
                    HousingUnitAvailableMapper housingUnit = new HousingUnitAvailableMapper()
                    {
                        HousingUnitId    = item.housingUnitId,
                        ProviderId       = item.providerId ?? 0,
                        AddressId        = item.addressId ?? 0,
                        HousingSignature = item.housingSignature,
                        Capacity         = item.capacity,

                        Address = address.GetAddress(item.addressId ?? 0),
                        Tenants = tenants.GetTenantsWithInfoByHousing(item.housingUnitId)
                    };

                    if (housingUnit.Tenants != null)
                    {
                        housingUnit.Occupied  = housingUnit.Tenants.Count();
                        housingUnit.Available = housingUnit.Capacity - housingUnit.Tenants.Count();
                    }
                    else
                    {
                        housingUnit.Occupied  = 0;
                        housingUnit.Available = housingUnit.Capacity;
                    }

                    housingUnits.Add(housingUnit);
                }
                return(housingUnits);
            }
        }
        // Get One housing unit with Tenants
        // DEFAULT
        // RETURNS ONE HOUSING UNIT WITH: Tenants with Batch, Contact, Gender, and Car Relationship
        public HousingUnitAvailableMapper GetHousingUnitsWithTenantsAvailable(int housingUnitId)
        {
            var content = db.HousingUnits.Where(j => j.housingUnitId == housingUnitId).FirstOrDefault();

            if (content == null)
            {
                return(null);
            }
            else
            {
                AddressesHelper            address     = new AddressesHelper();
                TenantsHelper              tenants     = new TenantsHelper();
                HousingUnitAvailableMapper housingUnit = new HousingUnitAvailableMapper()
                {
                    HousingUnitId    = content.housingUnitId,
                    ProviderId       = content.providerId ?? 0,
                    AddressId        = content.addressId ?? 0,
                    HousingSignature = content.housingSignature,
                    Capacity         = content.capacity,

                    Address = address.GetAddress(content.addressId ?? 0),
                    Tenants = tenants.GetTenantsWithInfoByHousing(content.housingUnitId)
                };

                if (housingUnit.Tenants != null)
                {
                    housingUnit.Occupied  = housingUnit.Tenants.Count();
                    housingUnit.Available = housingUnit.Capacity - housingUnit.Tenants.Count();
                }
                else
                {
                    housingUnit.Occupied  = 0;
                    housingUnit.Available = housingUnit.Capacity;
                }

                return(housingUnit);
            }
        }