Beispiel #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);
            }
        }
Beispiel #2
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);
            }
        }