public HttpResponseMessage DeleteUsers(int id) { if (Thread.CurrentPrincipal.Identity.AuthenticationType == "Admin") { string carError = "cant delete, there is car in that type"; carTypes carTypes = db.carTypes.FirstOrDefault(carType => carType.id == id); if (carTypes == null) { return(Request.CreateResponse(HttpStatusCode.BadRequest)); } else if (db.cars.Any(car => car.typeNumber == id)) { return(Request.CreateResponse(HttpStatusCode.BadRequest, carError)); } db.carTypes.Remove(carTypes); db.SaveChanges(); return(Request.CreateResponse(HttpStatusCode.OK)); } else { return(Request.CreateResponse(HttpStatusCode.BadRequest)); } }
public HttpResponseMessage updateAUser(int id, carTypes updateCarType) { if (Thread.CurrentPrincipal.Identity.AuthenticationType == "Admin") { if (db.carTypes.Any(car => car.id == id)) { carTypes carType = db.carTypes.FirstOrDefault(cars => cars.id == id); carType.maker = updateCarType.maker; carType.model = updateCarType.model; carType.dailyCost = updateCarType.dailyCost; carType.costOfOverdue = updateCarType.costOfOverdue; carType.gear = updateCarType.gear; carType.year = updateCarType.year; if (updateCarType.photo != null && updateCarType.photo != "") { carType.photo = updateCarType.photo; } db.SaveChanges(); return(Request.CreateResponse(HttpStatusCode.OK)); } return(Request.CreateResponse(HttpStatusCode.BadRequest)); } else { return(Request.CreateResponse(HttpStatusCode.BadRequest)); } }
void Start() { continueText.text = "Press [" + _EXIT_KEY_.ToString() + "] to continue"; textMoney.text = "$ " + PlayerPrefs.GetInt("money", 0).ToString(); // Generate new car if necessary if (PlayerPrefs.GetInt("new_car", -1) == -1) { carTypes car = GetNewCar(); Time.timeScale = 0; vehiclePanel.SetActive(true); vehicleText.text = car.ToString(); openPanel = vehiclePanel; PlayerPrefs.SetInt("new_car", (int)car); int idx = Random.Range(0, carColors.Count); PlayerPrefs.SetString("color", carColors[idx]); } else { UpdateCurrentCarPanel(); } interactionBubble.SetActive(false); FindObjectOfType <WorldCharacter>().SetPosition(new Vector3(PlayerPrefs.GetFloat("world_x", -4), -3, 0)); }
public HttpResponseMessage PostUsers(carTypes carTypes) { if (Thread.CurrentPrincipal.Identity.AuthenticationType == "Admin") { carTypes newcarTypes = new carTypes(); newcarTypes.maker = carTypes.maker; newcarTypes.model = carTypes.model; newcarTypes.year = carTypes.year; newcarTypes.gear = carTypes.gear; newcarTypes.dailyCost = carTypes.dailyCost; newcarTypes.costOfOverdue = carTypes.costOfOverdue; newcarTypes.photo = carTypes.photo; db.carTypes.Add(newcarTypes); db.SaveChanges(); return(Request.CreateResponse(HttpStatusCode.OK)); } else { return(Request.CreateResponse(HttpStatusCode.BadRequest)); } }