Example #1
0
        // Get All providers with contact
        // DEFAULT
        // RETURNS ALL PROVIDERS WITH: Contacts
        public IEnumerable <ProviderContactMapper> GetProvidersWithContact()
        {
            var content = db.Providers.ToList();

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

                        Contact = contact.GetContact(item.contactId ?? 0)
                    };
                    providers.Add(provider);
                }
                return(providers);
            }
        }
        // Get tenants of a housing unit with its supply request
        // INSIDE HELPER: USED IN HOUSING UNIT HELPER
        // RETURNS TENANTS BY HOUSING WITH: Supply Request with Mapping with Supplies
        public IEnumerable <TenantSupplyMapper> GetTenantsWithSupplies(int housingUnitId)
        {
            var content = db.Tenants.Where(j => j.housingUnitId == housingUnitId).ToList();

            if (content.Count() == 0)
            {
                return(null);
            }
            else
            {
                List <TenantSupplyMapper> tenants  = new List <TenantSupplyMapper>();
                SupplyRequestsHelper      requests = new SupplyRequestsHelper();
                ContactsHelper            contact  = new ContactsHelper();
                foreach (var item in content)
                {
                    TenantSupplyMapper tenant = new TenantSupplyMapper
                    {
                        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),

                        SupplyRequests = requests.GetSupplyRequestWithSupplies(item.tenantId),
                        Contact        = contact.GetContact(item.contactId ?? 0)
                    };
                    tenants.Add(tenant);
                }
                return(tenants);
            }
        }
        // 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);
            }
        }
Example #4
0
        // Get All management with contact
        // DEFAULT
        // RETURNS ALL MANAGERS WITH: Contacts
        public IEnumerable <ManagementContactMapper> GetManagementsWithContact()
        {
            var content = db.Managements.ToList();

            if (content.Count() == 0)
            {
                return(null);
            }
            else
            {
                List <ManagementContactMapper> managements = new List <ManagementContactMapper>();
                ContactsHelper contact = new ContactsHelper();
                foreach (var item in content)
                {
                    ManagementContactMapper management = new ManagementContactMapper
                    {
                        ManagerId      = item.managerId,
                        ContactId      = item.contactId ?? 0,
                        DepartmentName = item.departmentName,

                        Contact = contact.GetContact(item.contactId ?? 0)
                    };
                    managements.Add(management);
                }
                return(managements);
            }
        }
Example #5
0
        // Get One basic table
        // DEFAULT CRUD
        public ManagementMapper GetManagement(int managerId)
        {
            var content = db.Managements.FirstOrDefault(j => j.managerId == managerId);

            if (content == null)
            {
                return(null);
            }
            else
            {
                ContactsHelper   contact    = new ContactsHelper();
                ManagementMapper management = new ManagementMapper
                {
                    ManagerId      = content.managerId,
                    ContactId      = content.contactId ?? 0,
                    DepartmentName = content.departmentName
                };
                return(management);
            }
        }
        // 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);
            }
        }
Example #7
0
        // Get One provider with contact
        // DEFAULT
        // RETURNS ONE PROVIDER BY ID WITH: Contacts
        public ProviderContactMapper GetProviderWithContact(int providerId)
        {
            var content = db.Providers.FirstOrDefault(p => p.providerId == providerId);

            if (content == null)
            {
                return(null);
            }
            else
            {
                ContactsHelper        contact  = new ContactsHelper();
                ProviderContactMapper provider = new ProviderContactMapper
                {
                    ProviderId  = content.providerId,
                    ContactId   = content.contactId ?? 0,
                    CompanyName = content.companyName,

                    Contact = contact.GetContact(content.contactId ?? 0)
                };
                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);
            }
        }