Beispiel #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);
            }
        }
        // INSIDE HELPER: USED BY REQUESTS
        // RETURNS A TENANT BY ID WITH: Housing unit with Address
        public TenantRequestMapper GetTenantForRequests(int tenantId)
        {
            var content = db.Tenants.FirstOrDefault(j => j.tenantId == tenantId);

            if (content == null)
            {
                return(null);
            }
            else
            {
                HousingUnitsHelper  housingUnits = new HousingUnitsHelper();
                ContactsHelper      contact      = new ContactsHelper();
                TenantRequestMapper tenant       = new TenantRequestMapper
                {
                    TenantId      = content.tenantId,
                    ContactId     = content.contactId ?? 0,
                    BatchId       = content.batchId ?? 0,
                    HousingUnitId = content.housingUnitId ?? 0,
                    GenderId      = content.genderId ?? 0,
                    MoveInDate    = content.moveInDate,
                    HasMoved      = content.hasMoved ?? default(bool),
                    HasKey        = content.hasKey ?? default(bool),

                    HousingUnit = housingUnits.GetHousingUnitWithAddress(content.housingUnitId ?? 0),
                    Contact     = contact.GetContact(content.contactId ?? 0)
                };
                return(tenant);
            }
        }
        // DEFAULT
        // RETURNS TENANTS WITH: Housing unitt with Address, batch, contact, gender and car Relationship
        public IEnumerable <TenantInfoMapper> GetTenantsInfo()
        {
            var content = db.Tenants.ToList();

            if (content.Count() == 0)
            {
                return(null);
            }
            else
            {
                List <TenantInfoMapper>      tenants                = new List <TenantInfoMapper>();
                HousingUnitsHelper           housingUnits           = new HousingUnitsHelper();
                BatchesHelpers               batch                  = new BatchesHelpers();
                ContactsHelper               contact                = new ContactsHelper();
                GendersHelper                gender                 = new GendersHelper();
                TenantCarRelationshipsHelper tenantCarRelationships = new TenantCarRelationshipsHelper();
                foreach (var item in content)
                {
                    TenantInfoMapper tenant = new TenantInfoMapper
                    {
                        TenantId      = item.tenantId,
                        ContactId     = item.contactId ?? 0,
                        BatchId       = item.batchId ?? 0,
                        HousingUnitId = item.housingUnitId ?? 0,
                        GenderId      = item.genderId ?? 0,
                        MoveInDate    = item.moveInDate,
                        HasMoved      = item.hasMoved ?? default(bool),
                        HasKey        = item.hasKey ?? default(bool),

                        HousingUnit            = housingUnits.GetHousingUnitWithAddress(item.housingUnitId ?? 0),
                        Batch                  = batch.GetBatch(item.batchId ?? 0),
                        Contact                = contact.GetContact(item.contactId ?? 0),
                        Gender                 = gender.GetGender(item.genderId ?? 0),
                        TenantCarRelationships = tenantCarRelationships.GetTenantCarRelationship(item.tenantId)
                    };
                    tenants.Add(tenant);
                }
                return(tenants);
            }
        }
Beispiel #4
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);
            }
        }
        // DEFAULT: ONE TENANT WITH ALL INFO
        // RETURNS A TENANT BY ID WITH: Housing unit with Address, Batch, Contact, Gender and Car Relationship
        public TenantInfoMapper GetTenantInfo(int contactId)
        {
            var content = db.Tenants.FirstOrDefault(j => j.contactId == contactId);

            if (content == null)
            {
                return(null);
            }
            else
            {
                HousingUnitsHelper           housingUnits = new HousingUnitsHelper();
                BatchesHelpers               batch        = new BatchesHelpers();
                ContactsHelper               contact      = new ContactsHelper();
                GendersHelper                gender       = new GendersHelper();
                TenantCarRelationshipsHelper car          = new TenantCarRelationshipsHelper();

                TenantInfoMapper tenant = new TenantInfoMapper
                {
                    TenantId      = content.tenantId,
                    ContactId     = content.contactId ?? 0,
                    BatchId       = content.batchId ?? 0,
                    HousingUnitId = content.housingUnitId ?? 0,
                    GenderId      = content.genderId ?? 0,
                    MoveInDate    = content.moveInDate,
                    HasMoved      = content.hasMoved ?? default(bool),
                    HasKey        = content.hasKey ?? default(bool),

                    HousingUnit            = housingUnits.GetHousingUnitWithAddress(content.housingUnitId ?? 0),
                    Batch                  = batch.GetBatch(content.batchId ?? 0),
                    Contact                = contact.GetContact(content.contactId ?? 0),
                    Gender                 = gender.GetGender(content.genderId ?? 0),
                    TenantCarRelationships = car.GetTenantCarRelationship(content.tenantId)
                };
                return(tenant);
            }
        }