public void CanGetVehicleById() { var repo = new VehicleRepo(); VehicleUI vehicle = repo.GetVehicleById(3); Assert.IsNotNull(vehicle); }
public void CanAddVehicle() { VehicleUI vehicle = new VehicleUI(); var repo = new VehicleRepo(); vehicle.BodyStyleName = "Truck"; vehicle.ColorName = "Red"; vehicle.Featured = true; vehicle.ImageFileName = "images/2016fordescape.png"; vehicle.InteriorType = "Beige / Leather"; vehicle.Mileage = "18564"; vehicle.ModelName = "F-150"; vehicle.ModelYear = "2015"; vehicle.MSRP = 8500.00M; vehicle.New = false; vehicle.SalePrice = 7455.99M; vehicle.Sold = false; vehicle.TransmissionType = "Manual"; vehicle.VehicleDescription = "The best selling truck in America."; vehicle.VIN = "t0ta11EEL3g1t"; repo.InsertVehicle(vehicle); Assert.AreEqual(4, vehicle.VehicleId); }
public void UpdateVehicle(VehicleUI vehicle) { using (var cn = new SqlConnection("Server=localhost;Database=GuildCars;User Id=sa;Password=sqlserver;")) { SqlCommand cmd = new SqlCommand("UpdateVehicle", cn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@VehicleId", vehicle.VehicleId); cmd.Parameters.AddWithValue("@BodyStyleName", vehicle.BodyStyleName); cmd.Parameters.AddWithValue("@ColorName", vehicle.ColorName); cmd.Parameters.AddWithValue("@Featured", vehicle.Featured); cmd.Parameters.AddWithValue("@InteriorType", vehicle.InteriorType); cmd.Parameters.AddWithValue("@Mileage", vehicle.Mileage); cmd.Parameters.AddWithValue("@ModelName", vehicle.ModelName); cmd.Parameters.AddWithValue("@ModelYear", vehicle.ModelYear); cmd.Parameters.AddWithValue("@New", vehicle.New); cmd.Parameters.AddWithValue("@Sold", vehicle.Sold); cmd.Parameters.AddWithValue("@TransmissionType", vehicle.TransmissionType); cmd.Parameters.AddWithValue("@VehicleDescription", vehicle.VehicleDescription); cmd.Parameters.AddWithValue("@VIN", vehicle.VIN); cmd.Parameters.AddWithValue("@MSRP", vehicle.MSRP); cmd.Parameters.AddWithValue("@SalePrice", vehicle.SalePrice); cmd.Parameters.AddWithValue("@ImageFilePath", vehicle.ImageFileName); cn.Open(); cmd.ExecuteNonQuery(); } }
public ActionResult AddVehicle(AddEditVehicleVM addVehicleVM) { VehicleUI vehicle = new VehicleUI(); var repo = VehicleRepoFactory.CreateVehicleRepo(); if (ModelState.IsValid) { vehicle.MakeName = addVehicleVM.MakeName; vehicle.ModelName = addVehicleVM.ModelName; vehicle.BodyStyleName = addVehicleVM.BodyStyleName; vehicle.TransmissionType = addVehicleVM.TransmissionName; vehicle.ColorName = addVehicleVM.ColorName; vehicle.InteriorType = addVehicleVM.InteriorName; vehicle.ModelYear = addVehicleVM.Year; vehicle.Mileage = addVehicleVM.Mileage; vehicle.VIN = addVehicleVM.VIN; vehicle.New = addVehicleVM.Type; vehicle.Featured = addVehicleVM.Featured; vehicle.VehicleDescription = addVehicleVM.Description; vehicle.MSRP = addVehicleVM.MSRP; vehicle.SalePrice = addVehicleVM.SalePrice; repo.InsertVehicle(vehicle); if (addVehicleVM.UploadedImage != null && addVehicleVM.UploadedImage.ContentLength > 0) { string extension = Path.GetExtension(addVehicleVM.UploadedImage.FileName); string path = Path.Combine(Server.MapPath("~/Images"), Path.GetFileName("inventory-" + vehicle.VehicleId + extension)); string fileName = Path.GetFileName("inventory-" + vehicle.VehicleId + extension); addVehicleVM.UploadedImage.SaveAs(path); vehicle.ImageFileName = fileName; // maybe helpful blog post? https://asp-net-example.blogspot.in/2009/01/aspnet-fileupload-example-how-to-rename.html //FileUpload FileUpload1 = new FileUpload(); // //FileUpload1.SaveAs("~/Images/inventory" + vehicle.VehicleId + extension); } repo.UpdateVehicle(vehicle); return(RedirectToAction("EditVehicle/" + vehicle.VehicleId, "Admin")); } else { addVehicleVM.BodyStyle = GetBodyStylesSelectList(); addVehicleVM.Color = GetColorsSelectList(); addVehicleVM.Interior = GetInteriorsSelectList(); addVehicleVM.Make = GetMakeSelectList(); addVehicleVM.Model = GetModelSelectList(); addVehicleVM.Transmission = GetTransmissionSelectList(); return(View(addVehicleVM)); } }
public ActionResult Details(int id) { var repo = VehicleRepoFactory.CreateVehicleRepo(); VehicleUI vehicle = repo.GetVehicleById(id); return(View(vehicle)); }
public VehicleUI GetVehicleById(int vehicleId) { VehicleUI vehicle = new VehicleUI(); using (var cn = new SqlConnection("Server=localhost;Database=GuildCars;User Id=sa;Password=sqlserver;")) { SqlCommand cmd = new SqlCommand("DisplayVehicleById", cn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@VehicleId", vehicleId); cn.Open(); using (SqlDataReader dr = cmd.ExecuteReader()) { if (dr.Read()) { VehicleUI currentRow = new VehicleUI(); currentRow.BodyStyleName = dr["BodyStyleName"].ToString(); currentRow.ColorName = dr["ColorName"].ToString(); currentRow.Featured = (bool)dr["Featured"]; currentRow.ImageFileName = dr["ImageFilePath"].ToString(); currentRow.InteriorType = dr["InteriorType"].ToString(); currentRow.MakeName = dr["MakeName"].ToString(); currentRow.Mileage = dr["Mileage"].ToString(); currentRow.ModelName = dr["ModelName"].ToString(); currentRow.ModelYear = dr["ModelYear"].ToString(); currentRow.New = (bool)dr["New"]; currentRow.Sold = (bool)dr["Sold"]; currentRow.TransmissionType = dr["TransmissionType"].ToString(); currentRow.VehicleDescription = dr["VehicleDescription"].ToString(); currentRow.VehicleId = (int)dr["VehicleId"]; currentRow.VIN = dr["VIN"].ToString(); currentRow.MSRP = (int)dr["MSRP"]; if (dr["SalePrice"] != DBNull.Value) { currentRow.SalePrice = (int)dr["SalePrice"]; } vehicle = currentRow; } } } return(vehicle); }
public void InsertVehicle(VehicleUI vehicle) { using (var cn = new SqlConnection("Server=localhost;Database=GuildCars;User Id=sa;Password=sqlserver;")) { SqlCommand cmd = new SqlCommand("VehicleInsert", cn); cmd.CommandType = CommandType.StoredProcedure; SqlParameter param = new SqlParameter("@VehicleId", SqlDbType.Int); param.Direction = ParameterDirection.Output; cmd.Parameters.Add(param); cmd.Parameters.AddWithValue("@BodyStyleName", vehicle.BodyStyleName); cmd.Parameters.AddWithValue("@ColorName", vehicle.ColorName); cmd.Parameters.AddWithValue("@Featured", vehicle.Featured); cmd.Parameters.AddWithValue("@InteriorType", vehicle.InteriorType); cmd.Parameters.AddWithValue("@Mileage", vehicle.Mileage); cmd.Parameters.AddWithValue("@ModelName", vehicle.ModelName); cmd.Parameters.AddWithValue("@ModelYear", vehicle.ModelYear); cmd.Parameters.AddWithValue("@New", vehicle.New); cmd.Parameters.AddWithValue("@Sold", vehicle.Sold); cmd.Parameters.AddWithValue("@TransmissionType", vehicle.TransmissionType); cmd.Parameters.AddWithValue("@VehicleDescription", vehicle.VehicleDescription); cmd.Parameters.AddWithValue("@VIN", vehicle.VIN); cmd.Parameters.AddWithValue("@MSRP", vehicle.MSRP); cmd.Parameters.AddWithValue("@SalePrice", vehicle.SalePrice); if (string.IsNullOrEmpty(vehicle.ImageFileName)) { cmd.Parameters.AddWithValue("@ImageFilePath", DBNull.Value); } else { cmd.Parameters.AddWithValue("@ImageFilePath", vehicle.ImageFileName); } cn.Open(); cmd.ExecuteNonQuery(); vehicle.VehicleId = (int)param.Value; } }
public void CanGetVehicleInfo() { var repo = new VehicleRepo(); VehicleUI vehicle = repo.GetVehicleById(3); Assert.AreEqual(3, vehicle.VehicleId); Assert.AreEqual("Volvo", vehicle.MakeName); Assert.AreEqual("C-30", vehicle.ModelName); Assert.AreEqual("Hatchback", vehicle.BodyStyleName); Assert.AreEqual("Silver", vehicle.ColorName); Assert.AreEqual("Grey / White Racer", vehicle.InteriorType); Assert.AreEqual("Manual", vehicle.TransmissionType); Assert.AreEqual("2012", vehicle.ModelYear); Assert.AreEqual("45781", vehicle.Mileage); Assert.AreEqual(false, vehicle.New); Assert.AreEqual(true, vehicle.Featured); Assert.AreEqual(false, vehicle.Sold); Assert.AreEqual("a1b2c3d4e5f6g7h8i9j10", vehicle.VIN); Assert.AreEqual("The definition of a hot hatch.", vehicle.VehicleDescription); Assert.AreEqual("inventory-3.jpg", vehicle.ImageFileName); }
IEnumerator StartKeyInput() { do { // 총이 장착이 되었을때만 발사 가능 if (shotable == true) { if (Input.GetMouseButtonDown(0) && now_Weapon != -1) { if (now_Weapon >= 3) { bulletFinding = GetItem(2); } else if (now_Weapon == 2) { bulletFinding = GetItem(1); } else { bulletFinding = GetItem(now_Weapon); } if (bulletFinding != null && reloadBulletCount[now_Weapon] != 0) { Fire(bulletFinding); networkCtrl.Player_Shot(); } } } // 1번 , 2번 키 입력시 총 랜더링과 어떤 총인지 판별한다. if (Input.GetKeyDown(KeyCode.Alpha1) && weaponSlotNumber[0] != -1) { animator.SetBool("IsEquip", true); // 아래의 if else if문은 M4와 M16으로 총을 장착하였을 때 5.56mm의 종합적인 개수의 동기화를 위함. // 1번 장착 m16, 2번 장착 m4일때 if (weaponSlotNumber[0] == 1 && weaponSlotNumber[1] == 2) { bulletCount[1] = bulletCount[2]; } // 1번 장착 m4, 2번 장착 m16일때 else if (weaponSlotNumber[0] == 2 && weaponSlotNumber[1] == 1) { // m16의 토탈 불릿과 동일하게 m4 토탈 불릿을 개수 동기화 bulletCount[2] = bulletCount[1]; } now_Weapon = weaponSlotNumber[0]; weaponImage.GetComponent <Image>().sprite = weaponIEquipImage[now_Weapon]; weaponText.text = reloadBulletCount[now_Weapon] + " / " + bulletCount[now_Weapon]; for (int i = 0; i < 4; ++i) { if (now_Weapon == i) { weaponView[now_Weapon].GetComponent <Renderer>().enabled = true; } else { weaponView[i].GetComponent <Renderer>().enabled = false; } } } else if (Input.GetKeyDown(KeyCode.Alpha2) && weaponSlotNumber[1] != -1) { animator.SetBool("IsEquip", true); // 아래의 if else if문은 M4와 M16으로 총을 장착하였을 때 5.56mm의 종합적인 개수의 동기화를 위함. // 1번 장착 m16, 2번 장착 m4일때 if (weaponSlotNumber[0] == 1 && weaponSlotNumber[1] == 2) { bulletCount[2] = bulletCount[1]; } //1번 장착 m4, 2번 장착 m16일때 else if (weaponSlotNumber[0] == 2 && weaponSlotNumber[1] == 1) { bulletCount[1] = bulletCount[2]; } now_Weapon = weaponSlotNumber[1]; weaponImage.GetComponent <Image>().sprite = weaponIEquipImage[now_Weapon]; weaponText.text = reloadBulletCount[now_Weapon] + " / " + bulletCount[now_Weapon]; for (int i = 0; i < 4; ++i) { if (now_Weapon == i) { weaponView[now_Weapon].GetComponent <Renderer>().enabled = true; } else { weaponView[i].GetComponent <Renderer>().enabled = false; } } } // Tab키 입력시 인벤토리 코드 실행 if (Input.GetKeyDown(KeyCode.Tab)) { if (inventoryShow == false) { // 마우스 잠겨 있을경우 푼다. Cursor.lockState = CursorLockMode.None; //마우스 커서 고정 해제 Cursor.visible = true; //마우스 커서 보이기 inventory.SetActive(true); inventoryShow = true; RenewUpdate(); // 총 발사 잠금 shotable = false; } else if (inventoryShow == true) { // 마우스가 안점겨 있을경우 다시 잠군다. Cursor.lockState = CursorLockMode.Locked; //마우스 커서 고정 Cursor.visible = false; //마우스 커서 보이기 inventory.SetActive(false); inventoryShow = false; // 총 발사 잠금 해제 shotable = true; } } if (rideCar == true && GetTheCar == true && ridingCar.Car_Status == true && ridingCar.player_die == true) { //차량이 탑승 중에 차가 터진 경우 this.transform.position = new Vector3(ridingCar.transform.position.x - 1, ridingCar.transform.position.y, ridingCar.transform.position.z); PlayerDie(); networkCtrl.Player_HP(-1, hp, armour, "Car"); // 차량이 터지면서 hp는 0으로 만든다. } if (Input.GetKeyDown(KeyCode.G)) { if (rideCar == true && GetTheCar == false && ridingCar.Car_Status == false) { // 차량 탑승 여부를 나타냄 (탑승) GetTheCar = true; // 총 발사 가능 shotable = false; ridingCar.vehicleStop = false; CarNum = ridingCar.carNum; // 차량의 번호를 가지고 온다. ridingCar.Car_Status = true; networkCtrl.Car_Status(CarNum, true); // 차량 탑승했다고 서버에게 알린다. ridingCar.GetComponent <Rigidbody>().isKinematic = false; // 차량 탑승 하였으니 NavMesh Off navagent.enabled = false; // 캐릭터 캡슐 콜라이더 비활성화 gameObject.GetComponent <CapsuleCollider>().enabled = false; // 총구 앞 캡슐 콜라이더 비활성화 //firePos.GetComponent<CapsuleCollider>().enabled = false; // 차량 UI 활성화 VehicleUI.SetActive(true); vehicleHpBar.fillAmount = (float)ridingCar.vehicleHp / (float)ridingCar.vehicleInitHp; if (ridingCar.vehicleType.ToString() == "JEEP") { JEEPImage.SetActive(true); UAZImage.SetActive(false); } else if (ridingCar.vehicleType.ToString() == "UAZ") { UAZImage.SetActive(true); JEEPImage.SetActive(false); } // 차량 탑승시 PlayerModel에 있는 engine 사운드 재생 engineSource.Play(); } else if (rideCar == true && GetTheCar == true && ridingCar.Car_Status == true) { // 차량 탑승 여부를 나타냄 (하차) // 차량 탑승 가능한지 여부를 나타냄 rideCar = false; // 차량 하차했다고 서버에게 알린다. networkCtrl.Car_Status(CarNum, false); ridingCar.Car_Status = false; // 차량 하차 하였으니 NavMesh On navagent.enabled = true; // 차량을 내렸을 경우 차량 번호를 지운다. CarNum = -1; // 차량을 탑승 여부를 나타냄 (하차) GetTheCar = false; // 총 발사 가능 shotable = true; // 하차 후 차량 브레이크 작동 ridingCar.vehicleStop = true; ridingCar.GetComponent <Rigidbody>().isKinematic = true; // 차량 하차 시 좌표 이동 this.transform.position = new Vector3(ridingCar.transform.position.x - 1, ridingCar.transform.position.y, ridingCar.transform.position.z); // 캐릭터 캡슐 콜라이더 활성화 gameObject.GetComponent <CapsuleCollider>().enabled = true; // 총구 앞 캡슐 콜라이더 활성화 //firePos.GetComponent<CapsuleCollider>().enabled = true; // 차량 UI 비활성화 전 이미지 부터 비활성화 JEEPImage.SetActive(false); UAZImage.SetActive(false); // 차량 UI 비활성화 VehicleUI.SetActive(false); // 차량 하차시 PlayerModel에 있는 engine 사운드 멈춤 engineSource.Stop(); } } // 차량 탑승시 스페이스바로 경적 울림 if (Input.GetKeyDown(KeyCode.Space) && GetTheCar == true) { source.PlayOneShot(vehicleHornSound, 1.0f); } // R키를 누르면 재장전 if (Input.GetKeyDown(KeyCode.R)) { if (now_Weapon != -1 && bulletCount[now_Weapon] != 0) { cooltimeCtrl.ReloadCollTime(); } } if (Input.GetKeyDown(KeyCode.CapsLock)) { if (realView == false) { realMap.SetActive(true); realView = true; } else if (realView == true) { realMap.SetActive(false); realView = false; } } if (realView == true) { playerPositionImage.localPosition = new Vector3(-gameObject.transform.position.z * 0.5f, gameObject.transform.position.x * 0.5f); } //------------------------------------------------------------------------------ // 위치 이동 치트. if (Input.GetKeyDown(KeyCode.Alpha3)) // 낡은 공장 단지 { navagent.enabled = false; if (SingletonCtrl.Instance_S.NowMapNumber == 2) { tr.transform.position = new Vector3(875.8784f, 30.07964f, 2529.244f); } else { tr.transform.position = new Vector3(526.118f, 50.04224f, 2705.361f); } navagent.enabled = true; } else if (Input.GetKeyDown(KeyCode.Alpha4)) // 학교 { navagent.enabled = false; if (SingletonCtrl.Instance_S.NowMapNumber == 2) { tr.transform.position = new Vector3(653.0f, 30.05061f, 1855.0f); } else { tr.transform.position = new Vector3(1407.026f, 50.0f, 2190.113f); } navagent.enabled = true; } else if (Input.GetKeyDown(KeyCode.Alpha5)) // 언덕위 집 { navagent.enabled = false; if (SingletonCtrl.Instance_S.NowMapNumber == 2) { tr.transform.position = new Vector3(654.1024f, 30.05061f, 968.7f); } else { tr.transform.position = new Vector3(718.0281f, 50.0f, 1235.498f); } navagent.enabled = true; } else if (Input.GetKeyDown(KeyCode.Alpha6)) // 컨테이너 단지 { navagent.enabled = false; if (SingletonCtrl.Instance_S.NowMapNumber == 2) { tr.transform.position = new Vector3(1001.0f, 30.07964f, 988.0f); } else { tr.transform.position = new Vector3(349.1992f, 60.06981f, 376.0149f); } navagent.enabled = true; } else if (Input.GetKeyDown(KeyCode.Alpha7)) // 호수 옆 집 { navagent.enabled = false; if (SingletonCtrl.Instance_S.NowMapNumber == 2) { tr.transform.position = new Vector3(1572.333f, 30.07964f, 923.0f); } else { tr.transform.position = new Vector3(1545.017f, 59.95751f, 904.9451f); } navagent.enabled = true; } else if (Input.GetKeyDown(KeyCode.Alpha8)) // 센터 { navagent.enabled = false; if (SingletonCtrl.Instance_S.NowMapNumber == 2) { tr.transform.position = new Vector3(1390.741f, 30.08651f, 2121.12f); } else { tr.transform.position = new Vector3(1008.397f, 30.06981f, 1553.832f); } navagent.enabled = true; } else if (Input.GetKeyDown(KeyCode.Alpha9)) // 센터 { navagent.enabled = false; if (SingletonCtrl.Instance_S.NowMapNumber == 2) { tr.transform.position = new Vector3(1647.643f, 64.04927f, 2341.669f); } else { tr.transform.position = new Vector3(1008.397f, 30.06981f, 1553.832f); } navagent.enabled = true; } else if (Input.GetKeyDown(KeyCode.Alpha0)) { // Navmesh ON/OFF if (navagent.enabled == true) { navagent.enabled = false; } else { navagent.enabled = true; } } //------------------------------------------------------------------------------ if (playerState == PlayerState.die) { ScreenSceneOFF.color += new Color(0f, 0f, 0f, 0.003f); if (ScreenSceneOFF.color.a >= 1.0f) { // 플레이어 모든 코루틴 종료 SceneManager.LoadScene("DieGameScene"); // 다음씬으로 넘어감 } } if (SingletonCtrl.Instance_S.SurvivalPlayer == 1 && playerState != PlayerState.die) { ScreenSceneOFF.gameObject.SetActive(true); Cursor.lockState = CursorLockMode.None; //마우스 커서 고정 해제 Cursor.visible = true; //마우스 커서 보이기 ScreenSceneOFF.color += new Color(0f, 0f, 0f, 0.003f); if (ScreenSceneOFF.color.a >= 1.0f) { // 플레이어 모든 코루틴 종료 SceneManager.LoadScene("WinGameScene"); // 다음씬으로 넘어감 } } yield return(null); } while (true); //yield return null; }
public List <VehicleUI> SearchUsedVehicles(Search parameters) { List <VehicleUI> vehicles = new List <VehicleUI>(); using (var cn = new SqlConnection("Server=localhost;Database=GuildCars;User Id=sa;Password=sqlserver;")) { SqlCommand cmd = new SqlCommand("SearchUsedVehicles", cn); cmd.CommandType = CommandType.StoredProcedure; if (parameters.SearchTerm == null) { cmd.Parameters.AddWithValue("@Searchterm", DBNull.Value); } else { cmd.Parameters.AddWithValue("@SearchTerm", parameters.SearchTerm); } if (parameters.MinYear == null) { cmd.Parameters.AddWithValue("@MinYear", DBNull.Value); } else { cmd.Parameters.AddWithValue("@MinYear", parameters.MinYear); } if (parameters.MaxYear == null) { cmd.Parameters.AddWithValue("@MaxYear", DBNull.Value); } else { cmd.Parameters.AddWithValue("@MaxYear", parameters.MaxYear); } if (parameters.MinPrice == null) { cmd.Parameters.AddWithValue("@MinPrice", DBNull.Value); } else { cmd.Parameters.AddWithValue("@MinPrice", parameters.MinPrice); } if (parameters.MaxPrice == null) { cmd.Parameters.AddWithValue("@MaxPrice", DBNull.Value); } else { cmd.Parameters.AddWithValue("@MaxPrice", parameters.MaxPrice); } cn.Open(); using (SqlDataReader dr = cmd.ExecuteReader()) { while (dr.Read()) { VehicleUI currentRow = new VehicleUI(); currentRow.BodyStyleName = dr["BodyStyleName"].ToString(); currentRow.ColorName = dr["ColorName"].ToString(); currentRow.Featured = (bool)dr["Featured"]; currentRow.ImageFileName = dr["ImageFilePath"].ToString(); currentRow.InteriorType = dr["InteriorType"].ToString(); currentRow.MakeName = dr["MakeName"].ToString(); currentRow.Mileage = dr["Mileage"].ToString(); currentRow.ModelName = dr["ModelName"].ToString(); currentRow.ModelYear = dr["ModelYear"].ToString(); currentRow.New = (bool)dr["New"]; currentRow.Sold = (bool)dr["Sold"]; currentRow.TransmissionType = dr["TransmissionType"].ToString(); currentRow.VehicleDescription = dr["VehicleDescription"].ToString(); currentRow.VehicleId = (int)dr["VehicleId"]; currentRow.VIN = dr["VIN"].ToString(); currentRow.MSRP = (int)dr["MSRP"]; if (dr["SalePrice"] != DBNull.Value) { currentRow.SalePrice = (int)dr["SalePrice"]; } vehicles.Add(currentRow); } } } return(vehicles); }
public static void LoadData() { Files.AdjustPath(); VehicleUI.LoadVehicles(Files.VehicleFullPath); //VehicleUI.PrintVehicles(); }
public static void SaveData() { VehicleUI.SaveVehicle(Files.VehicleFullPath); }