Esempio n. 1
0
        // Get All providers with units
        // DEFAULT
        // RETURNS ALL PROVIDERS WITH: Housing Units with Address
        public IEnumerable <ProviderUnitsMapper> GetProvidersWithUnits()
        {
            var content = db.Providers.ToList();

            if (content.Count() == 0)
            {
                return(null);
            }
            else
            {
                List <ProviderUnitsMapper> providers = new List <ProviderUnitsMapper>();
                HousingUnitsHelper         housing   = new HousingUnitsHelper();
                foreach (var item in content)
                {
                    ProviderUnitsMapper provider = new ProviderUnitsMapper
                    {
                        ProviderId  = item.providerId,
                        ContactId   = item.contactId ?? 0,
                        CompanyName = item.companyName,

                        HousingUnits = housing.GetHousingUnitsWithAddressbyProvider(item.providerId)
                    };
                    providers.Add(provider);
                }
                return(providers);
            }
        }
Esempio n. 2
0
        // Get One provider with units
        // DEFAULT
        // RETURNS ONE PROVIDER WITH: Housing Units with Address
        public ProviderUnitsMapper GetProviderWithUnits(int providerId)
        {
            var content = db.Providers.FirstOrDefault(p => p.providerId == providerId);

            if (content == null)
            {
                return(null);
            }
            else
            {
                HousingUnitsHelper  housing  = new HousingUnitsHelper();
                ProviderUnitsMapper provider = new ProviderUnitsMapper
                {
                    ProviderId  = content.providerId,
                    ContactId   = content.contactId ?? 0,
                    CompanyName = content.companyName,

                    HousingUnits = housing.GetHousingUnitsWithAddressbyProvider(content.providerId)
                };
                return(provider);
            }
        }