Esempio n. 1
0
        } //-end of ViewAllHybrid()-

        // case 8
        private void AddNewHybrid()
        {
            Console.Clear();

            HybridClass newHybrid = new HybridClass();

            // Make
            Console.WriteLine("Enter the make of the vehicle:");
            newHybrid.Make = Console.ReadLine().ToUpper();
            // Model
            Console.WriteLine("Enter the model of the vehicle:");
            newHybrid.Model = Console.ReadLine();
            // Year
            Console.WriteLine("Enter the year of the vehicle:");
            string yearAsString = Console.ReadLine();

            newHybrid.Year = int.Parse(yearAsString);
            // Price
            Console.WriteLine("How much did the vehicle cost? Do not use a dollar sign($). No commas needed.:");
            string priceAsString = Console.ReadLine();

            newHybrid.Price = int.Parse(priceAsString);
            // Miles
            Console.WriteLine("What is the highest number of miles it can drive fully charged or with a full tank of gas? Enter the highest number. (Numbers only please).");
            string milesAsString = Console.ReadLine();

            newHybrid.Miles = int.Parse(milesAsString);

            _hybridRepo.AddHybridToList(newHybrid);
        } //-end of AddNewHybrid()-
Esempio n. 2
0
        //  public ActionResult InsertMasterData(MasterTable _Master)
        public ActionResult InsertMasterData(HybridClass _obj)

        {
            //string _FolderPath = "~/FileFolder/UserRegFiles";
            //string _fileName = _obj.ProjectInformation.FileName;
            //string _fileExt = System.IO.Path.GetExtension(_fileName);
            //bool exists = System.IO.Directory.Exists(Server.MapPath(_FolderPath));
            //if (!exists)
            //    System.IO.Directory.CreateDirectory(Server.MapPath(_FolderPath));
            // string _folderPath= DateTime.Now.ToString("yyyyMMddHHmmssfff") + "_" + Guid.NewGuid().ToString("N")+ _fileExt;
            //var path = System.IO.Path.Combine(Server.MapPath(_FolderPath), _folderPath);

            //  _obj.ProjectInformation.SaveAs(path);
            MasterTable _objmaster = new MasterTable();

            _objmaster.Master_Email = Request.Form["_MasterTable.Master_Email"];
            _objmaster.PassWord     = Request.Form["_MasterTable.PassWord"];
            _objmaster.Master_Name  = Request.Form["_MasterTable.Master_Name"];
            //  _objmaster.ImageId = Convert.ToInt16(Request.Form["_MasterTable.ImageId"]);
            _objmaster.ImageId = 1;

            _objmaster.ContryId = Convert.ToInt16(Request.Form["_MasterTable.ContryId"]);
            _objmaster.StateId  = Convert.ToInt16(Request.Form["_MasterTable.StateId"]);
            _objmaster.CityId   = Convert.ToInt16(Request.Form["_MasterTable.CityId"]);
            if (ModelState.IsValid)
            {
                int res = _ObjRepo.InsertData(_objmaster);
                return(RedirectToAction("Index"));
            }
            return(View("Index"));
        }
Esempio n. 3
0
        public void AddHybridToList_ShouldWork()
        {
            HybridRepo  testRepo  = new HybridRepo();
            HybridClass newHybrid = new HybridClass {
                Make = "Mitsubishi", Model = "Lancer", Year = 4, Price = 2, Miles = 1
            };
            List <HybridClass> _listOfHybrids = new List <HybridClass>();

            // Act
            _listOfHybrids.Add(newHybrid);

            // Assert
            Assert.IsTrue(_listOfHybrids.Count > 0);
        }
Esempio n. 4
0
        public ActionResult Index(HybridClass _hybrid)
        {
            HybridClass _objHybrid   = new HybridClass();
            var         _MasterData  = _ObjRepo.GetMasterTableData();
            var         _CountryData = _ObjRepo.GetCountry().ToList();

            _objHybrid.GetMasterData = _MasterData;
            var _CountryListData = _ObjRepo.GetCountry();

            _objHybrid.GetCountryData = _CountryListData;
            //ViewBag.countrlist = _CountryData.Select(x => new SelectListItem
            //{
            //    Text = x.Cnt_Name.ToString(),
            //    Value = x.Cnt_Id.ToString()
            //});
            return(View("Index", _objHybrid));
        }
Esempio n. 5
0
        // Here are some pre-made vehicles I want inside the app
        private void SeedMealList()
        {
            ElectricClass extesla   = new ElectricClass("TESLA", "Model X", 2020, 79990, 351);
            ElectricClass exnissan  = new ElectricClass("NISSAN", "LEAF", 2020, 31600, 226);
            ElectricClass exjaguar  = new ElectricClass("JAGUAR", "I-PACE", 2020, 69850, 234);
            GasClass      exhonda   = new GasClass("HONDA", "Civic", 2021, 22000, 40);
            GasClass      exhyundai = new GasClass("HYUNDAI", "Elantra", 2020, 19300, 41);
            GasClass      extoyota  = new GasClass("TOYOTA", "Avalon", 2021, 35875, 34);
            HybridClass   exkia     = new HybridClass("KIA", "Optima", 2021, 30490, 32);

            _electricRepo.AddElectricToList(extesla);
            _electricRepo.AddElectricToList(exnissan);
            _electricRepo.AddElectricToList(exjaguar);
            _gasRepo.AddGasToList(exhonda);
            _gasRepo.AddGasToList(exhyundai);
            _gasRepo.AddGasToList(extoyota);
            _hybridRepo.AddHybridToList(exkia);
        }
Esempio n. 6
0
        // case 12
        private void UpdateExistingHybrid()
        {
            Console.WriteLine("Enter the make of the vehicle you'd like to update:");
            string      oldMake = Console.ReadLine();
            HybridClass newMake = new HybridClass();

            // Make
            Console.WriteLine("Enter the make of the vehicle:");
            newMake.Make = Console.ReadLine().ToUpper();
            // Model
            Console.WriteLine("Enter the model of the vehicle:");
            newMake.Model = Console.ReadLine();
            // Year
            Console.WriteLine("Enter the year of the vehicle:");
            string yearAsString = Console.ReadLine();

            newMake.Year = int.Parse(yearAsString);
            // Price
            Console.WriteLine("How much did the vehicle cost? Do not use a dollar sign($). No commas needed.:");
            string priceAsString = Console.ReadLine();

            newMake.Price = int.Parse(priceAsString);
            // Miles
            Console.WriteLine("How many miles can it drive on a fully charged battery? (Numbers only please)");
            string milesAsString = Console.ReadLine();

            newMake.Miles = int.Parse(milesAsString);

            bool wasUpdated = _hybridRepo.UpdateExistingHybrid(oldMake, newMake);

            if (wasUpdated)
            {
                Console.WriteLine("Vehicle successfully updated!");
            }
            else
            {
                Console.WriteLine("Could not update vehicle.");
            }
        }
Esempio n. 7
0
        public void RemoveHybridFromList_ShouldWork()
        {
            HybridRepo  testRepo  = new HybridRepo();
            HybridClass newHybrid = new HybridClass {
                Make = "Mitsubishi", Model = "Lancer", Year = 4, Price = 2, Miles = 1
            };
            List <HybridClass> _listOfHybrids = new List <HybridClass>();

            _listOfHybrids.Add(newHybrid);

            int initialHybrid = _listOfHybrids.Count;

            _listOfHybrids.Remove(newHybrid);

            if (initialHybrid > _listOfHybrids.Count)
            {
                Console.WriteLine("true");
            }
            else
            {
                Console.WriteLine("false");
            }
        }