Exemple #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);
        }
Exemple #2
0
        public List <DealerDto> ListOfDealer()
        {
            var listOfDealers = new List <DealerDto>();

            using (var context = new AppicoContext())
            {
                var repository = new DealerRepository();
                listOfDealers = repository.InitRepository(context)
                                .AllDealers()
                                .Select(d => new DealerDto()
                {
                    guid = d.guid,
                    Name = d.name
                }).ToList();
            }
            return(listOfDealers);
        }
Exemple #3
0
        public List <ModelDto> ListOfModels()
        {
            var listOfModels = new List <ModelDto>();

            using (var context = new AppicoContext())
            {
                var repository = new ModelRepository();
                listOfModels = repository.InitRepository(context)
                               .AllModels()
                               .Select(m => new ModelDto()
                {
                    guid  = m.guid,
                    Model = $"{m.make}-{m.model}-{m.type}"
                }).ToList();
            }
            return(listOfModels);
        }
Exemple #4
0
 public void CreateNewContact(ContactInputDto contactDto)
 {
     using (var context = new AppicoContext())
     {
         var repository = new ContactRepository();
         repository.InitRepository(context)
         .AddNewContact(new contact
         {
             guid    = repository.GetLastId(),
             name    = contactDto.Name,
             email   = contactDto.Email,
             created = DateTime.UtcNow,
             dealer  = contactDto.DealerId,
             model   = contactDto.ModelId,
             message = contactDto.Message
         }).Save();
     }
 }
Exemple #5
0
        public List <InventoryDto> ListOfInventory()
        {
            var listOfInventory = new List <InventoryDto>();

            using (var context = new AppicoContext())
            {
                var repository = new InventoryRepository();
                listOfInventory = repository.InitRepository(context)
                                  .AllInventories()
                                  .Select(i => new InventoryDto()
                {
                    VIN        = i.vin,
                    DealerName = i.dealer1.name,
                    ModelMake  = i.models.make,
                    ModelName  = i.models.model,
                    ModelType  = i.models.type
                }).ToList();
            }
            return(listOfInventory);
        }
Exemple #6
0
 public ModelRepository InitRepository(AppicoContext context)
 {
     _context = context;
     DbSet    = context.models;
     return(this);
 }
Exemple #7
0
 public DealerRepository InitRepository(AppicoContext context)
 {
     _context = context;
     DbSet    = context.dealer;
     return(this);
 }
Exemple #8
0
 public InventoryRepository InitRepository(AppicoContext context)
 {
     _context = context;
     DbSet    = context.inventory;
     return(this);
 }