protected void submitBtn_Click(object sender, EventArgs e) { Distance distanceToTravel = new Distance(); distanceToTravel.miles = Convert.ToDecimal(distanceTxtBox.Text); carServiceObj.CalculateFuel(carServiceObj.GetById(Guid.Parse(idTxtBox.Text)), distanceToTravel); Response.Redirect("CarWebPageView.aspx"); }
public void SelectById() { Console.Write("Id: "); try { Guid carId = Guid.Parse(Console.ReadLine()); Select(carServicesObj.GetById(carId)); } catch (NullReferenceException) { Console.WriteLine("No cars matching this Id in database\n"); } catch (Exception x) { Console.WriteLine(x.Message + "\n"); } }
public ActionResult <Cars> Get(int id) { var car = carService.GetById(id); if (car != null) { return(Ok(car)); } return(NotFound()); }
private void fillTable() { Car carToEdit = carServicesObj.GetById(Guid.Parse(idTxtBox.Text)); foreach (var item in carToEdit.passengers) { TableRow passengerRow = new TableRow(); TableCell idCell = new TableCell(); idCell.Text = item.Id.ToString(); passengerRow.Cells.Add(idCell); TableCell firstNameCell = new TableCell(); firstNameCell.Text = item.firstName; passengerRow.Cells.Add(firstNameCell); TableCell lastNameCell = new TableCell(); lastNameCell.Text = item.lastName; passengerRow.Cells.Add(lastNameCell); passengerTable.Rows.Add(passengerRow); } }
public string EditCarInfo([FromBody] EditCarInfoRequest request) { var result = new CommonBaseInfo(); if (request.id.PackInt() > 0) { var model = _repository.GetById(request.id.PackInt()); if (model == null) { result.ResultMsg = "未查询到车辆信息"; result.StateCode = 404; return(JsonConvert.SerializeObject(result)); } Car newCar = new Car { id = Convert.ToInt32(request.id), carBrand = request.carBrand, carColor = request.carColor, carLicenseImg = request.carLicenseImg, carMasterId = request.carMasterId.PackInt(), carNo = request.carNo, carSeatNum = request.carSeatNum.PackInt(), carType = request.carType.PackInt() }; var update = _repository.Edit(newCar); if (update) { result.ResultMsg = "编辑成功"; result.StateCode = 200; } } else { Car newCar = new Car { carBrand = request.carBrand, carColor = request.carColor, carLicenseImg = request.carLicenseImg, carMasterId = request.carMasterId.PackInt(), carNo = request.carNo, carSeatNum = request.carSeatNum.PackInt(), carType = request.carType.PackInt() }; var add = _repository.Add(newCar); if (add == null) { result.ResultMsg = "新增失败"; result.StateCode = 201; return(JsonConvert.SerializeObject(result)); } result.ResultMsg = "新增成功"; result.StateCode = 200; } return(JsonConvert.SerializeObject(result)); }
protected void submitEditBtn_Click(object sender, EventArgs e) { carToEdit = carServicesObj.GetById(Guid.Parse(idTxtBox.Text)); carToEdit.vehicleName = vehicleNameTxtBox.Text; carToEdit.numberPlate = numberPlateTxtBox.Text; switch (carTypeDdl.Text) { case "Unknown": carToEdit.carType = Car.CarType.Unknown; break; case "Hatchback": carToEdit.carType = Car.CarType.Hatchback; break; case "Sedan": carToEdit.carType = Car.CarType.Sedan; break; case "SUV": carToEdit.carType = Car.CarType.SUV; break; case "Coupe": carToEdit.carType = Car.CarType.Coupe; break; case "Convertible": carToEdit.carType = Car.CarType.Convertible; break; } carToEdit.weight.kilograms = Convert.ToDecimal(weightTxtBox.Text); carToEdit.maximumFuel.litres = Convert.ToDecimal(fuelCapacityTxtBox.Text); carToEdit.milage.milesPerGallon = Convert.ToDecimal(milageTxtBox.Text); carToEdit.maximumPassengers = Convert.ToInt32(passengerCapacityTxtBox.Text); carServicesObj.Update(carToEdit); Response.Redirect("CarWebPageView.aspx"); }
protected void submitBtn_Click(object sender, EventArgs e) { carServicesObj.Delete(carServicesObj.GetById(Guid.Parse(idTxtBox.Text))); Response.Redirect("CarWebPageView.aspx"); }