public void List() { IList <Car> carList = carServicesObj.GetAll(); foreach (Car selectedCar in carList) { PrintInfo(selectedCar, true); } }
public void FillCarList() { IList <Car> allCars = carServicesObj.GetAll(); carList.Items.Clear(); foreach (var currentCar in allCars) { ListViewItem carItem = new ListViewItem(currentCar.vehicleName); carItem.SubItems.Add(currentCar.numberPlate); carItem.SubItems.Add(currentCar.carType.ToString()); carItem.SubItems.Add(string.Format("{0} kg", decimal.Round(currentCar.weight.kilograms, 2))); carItem.SubItems.Add(string.Format("{0}/{1} l", decimal.Round(currentCar.currentFuel.litres, 2), decimal.Round(currentCar.maximumFuel.litres, 2))); carItem.SubItems.Add(string.Format("{0} mpg", decimal.Round(currentCar.milage.milesPerGallon, 2))); carItem.SubItems.Add(string.Format("{0}/{1}", currentCar.passengers.Count, currentCar.maximumPassengers)); carList.Items.Add(carItem); } }
private void PopulateCarsTable() { IList <Car> carList = carServicesObj.GetAll(); foreach (var item in carList) { TableRow newTableRow = new TableRow(); TableCell IdTableCell = new TableCell(); IdTableCell.Text = item.Id.ToString(); newTableRow.Cells.Add(IdTableCell); TableCell nameTableCell = new TableCell(); nameTableCell.Text = item.vehicleName; newTableRow.Cells.Add(nameTableCell); TableCell numberplateTableCell = new TableCell(); numberplateTableCell.Text = item.numberPlate; newTableRow.Cells.Add(numberplateTableCell); TableCell carTypeTableCell = new TableCell(); carTypeTableCell.Text = item.carType.ToString(); newTableRow.Cells.Add(carTypeTableCell); TableCell weightTableCell = new TableCell(); weightTableCell.Text = decimal.Round(item.weight.kilograms, 2).ToString(); newTableRow.Cells.Add(weightTableCell); TableCell milageTableCell = new TableCell(); milageTableCell.Text = decimal.Round(item.milage.milesPerGallon, 2).ToString(); newTableRow.Cells.Add(milageTableCell); TableCell fuelTableCell = new TableCell(); fuelTableCell.Text = string.Format("{0}/{1}L", decimal.Round(item.currentFuel.litres, 2), decimal.Round(item.maximumFuel.litres, 2)); newTableRow.Cells.Add(fuelTableCell); TableCell passengerTableCell = new TableCell(); passengerTableCell.Text = string.Format("{0}/{1}", item.passengers.Count, item.maximumPassengers);; newTableRow.Cells.Add(passengerTableCell); carsTable.Rows.Add(newTableRow); } }
public ActionResult <IEnumerable <Cars> > GetAll() { return(Ok(carService.GetAll())); }