static void DescribeAutomobile(Automobile automobile)
 {
     Console.WriteLine($"This automobile is a {automobile.GetType().Name}");
 }
        public ActionResult FullSearch(Automobile automobile)
        {
            var offers              = _context.Offers.ToList();
            List <Automobile> cars  = new List <Automobile>();
            List <Automobile> autos = new List <Automobile>();

            PropertyInfo[] properties = automobile.GetType().GetProperties();
            var            listAutos  = _context.Automobiles
                                        .Include(a => a.NumberOfDoor)
                                        .Include(a => a.CarBody)
                                        .Include(a => a.Gearshift).ToList();

            for (int i = 0; i < listAutos.Count(); i++)
            {
                for (int j = 0; j < offers.Count(); j++)
                {
                    if (listAutos.ElementAt(i).Id == offers.ElementAt(j).AutomobileId)
                    {
                        cars.Add(listAutos.ElementAt(i));
                        break;
                    }
                }
            }
            foreach (Automobile auto in cars)
            {
                int count1    = 0;
                int count2    = 0;
                int countProp = 0;
                foreach (PropertyInfo property in properties)
                {
                    if (countProp < (properties.Count() - 1))
                    {
                        if (property.GetValue(automobile, null) != null)
                        {
                            string propAuto = property.GetValue(automobile, null).ToString();
                            if (propAuto != "" && propAuto != "0")
                            {
                                string name = property.Name;
                                string prop = property.GetValue(auto, null).ToString();
                                if (prop.Equals(automobile[name]))
                                {
                                    count1++;
                                }
                                count2++;
                            }
                        }
                    }
                    countProp++;
                }
                if (count1 == count2)
                {
                    autos.Add(auto);
                }
            }
            var viewModel = new Object();

            if (autos.Count() > 0)
            {
                viewModel = new NewRandomViewModel
                {
                    Automobile    = new Automobile(),
                    Automobiles   = autos,
                    SearchesAutos = autos,
                    NumberOfDoors = _context.NumberOfDoors.ToList(),
                    Gearshifts    = _context.Gearshifts.ToList(),
                    CarBodies     = _context.CarBodies.ToList()
                };
            }
            else
            {
                viewModel = new NewRandomViewModel
                {
                    Automobile    = new Automobile(),
                    Automobiles   = autos,
                    SearchesAutos = cars,
                    NumberOfDoors = _context.NumberOfDoors.ToList(),
                    Gearshifts    = _context.Gearshifts.ToList(),
                    CarBodies     = _context.CarBodies.ToList()
                };
            }
            return(View("Index", viewModel));
        }