Пример #1
0
        public List <ContactOutputDto> ListOfContacts()
        {
            var listOfContacts = new List <ContactOutputDto>();

            using (var context = new AppicoContext())
            {
                var contactRepository = new ContactRepository().InitRepository(context);
                var dealerRepository  = new DealerRepository().InitRepository(context);
                var modelRepository   = new ModelRepository().InitRepository(context);
                listOfContacts = (from contactData in contactRepository.AllContacts()
                                  join dealerData in dealerRepository.AllDealers() on
                                  contactData.dealer equals dealerData.guid
                                  join modelData in modelRepository.AllModels() on
                                  contactData.model equals modelData.guid
                                  select new ContactOutputDto()
                {
                    Name = contactData.name,
                    EMail = contactData.email,
                    DealerName = dealerData.name,
                    ModelMake = modelData.make,
                    ModelName = modelData.model,
                    ModelType = modelData.type,
                    Message = contactData.message != null ? contactData.message: string.Empty,
                    CreatedDate = contactData.created.ToShortDateString()
                }).ToList();
            }
            return(listOfContacts);
        }