private void askTruckDetails(Vehical i_Vehical) { Truck truck = i_Vehical as Truck; askCargoholdVolume(truck); askIfCargoholdCooled(truck); }
private void askEngineDetails(Vehical i_Vehical) { Console.Clear(); while (true) { try { Console.Write("Please enter the engines current capacity: "); i_Vehical.Engine.CurrentCapacity = float.Parse(Console.ReadLine()); break; } catch (GarageLogic.ValueOutOfRangeException ex) { Console.WriteLine(ex.Message); } catch (ArgumentException ex) { Console.WriteLine(ex.Message); } catch (FormatException ex) { Console.WriteLine(ex.Message); } } }
private void askMotorcycleDetails(Vehical i_Vehical) { Motorcycle motorcycle = i_Vehical as Motorcycle; askLicenseTypes(motorcycle); askEngineVolume(motorcycle); }
private void askCarDetails(Vehical i_Vehical) { Console.Clear(); Car car = i_Vehical as Car; askForColor(car); askForNumberOfDoors(car); }
// GET api/VehicalAPI/5 public Vehical GetVehical(int id) { Vehical vehical = db.Vehicals.Single(v => v.VehicalID == id); if (vehical == null) { throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.NotFound)); } return(vehical); }
public static ObjectId AddVehical(Vehical v) { var connectionString = "mongodb://localhost/?safe=true"; var server = MongoServer.Create(connectionString); var db = server.GetDatabase("TransportSystem"); var collectionVehical = db.GetCollection <Vehical>("Vehical"); collectionVehical.Insert(v); return(v.Id); }
public Vihecal(MongoLayer.Models.Vehical vh = null, VihecalType type = null) { InitializeComponent(); comboBox1.Items.Add("ChoseType"); comboBox1.SelectedIndex = 0; comboBox1.Items.AddRange(types.ToArray()); panel1.Visible = false; panel2.Visible = false; panel3.Visible = false; if (vh != null) { vihecal = vh; this.type = type; textBox1.Text = vh.CurrentCond; if (type.name.Equals("Bus")) { panel1.Visible = true; // panel2.Visible = false; // panel3.Visible = false; panel2.Hide(); panel3.Hide(); comboBox1.SelectedIndex = 1; textBox2.Text = (vh as Bus).NumOfPassengers.ToString(); } else if (type.name.Equals("Vagon")) { panel1.Visible = true; // panel2.Visible = false; // panel3.Visible = false; panel2.Hide(); panel3.Hide(); comboBox1.SelectedIndex = 2; textBox2.Text = (vh as Vagon).NumOfPassengers.ToString(); } else if (type.name.Equals("Voz")) { // panel1.Visible = false; // panel2.Visible = false; panel3.Visible = true; panel2.Hide(); panel1.Hide(); comboBox1.SelectedIndex = 3; textBox4.Text = (vh as Locomotiva).MaximumPulingCapacity.ToString(); listBox1.Items.AddRange(VehicalModel.GetAllVagons(vh.Id).ToArray()); } comboBox1.Enabled = false; } listBox2.Items.AddRange(VehicalModel.GetAllVagons().ToArray()); }
// POST api/VehicalAPI public HttpResponseMessage PostVehical(Vehical vehical) { if (ModelState.IsValid) { db.Vehicals.AddObject(vehical); db.SaveChanges(); HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Created, vehical); response.Headers.Location = new Uri(Url.Link("DefaultApi", new { id = vehical.VehicalID })); return(response); } else { return(Request.CreateResponse(HttpStatusCode.BadRequest)); } }
private bool UpdateVihecal() { Vehical bs = vihecal; bs.Type = (comboBox1.SelectedItem as VihecalType).name; bs.LastCheck = dateTimePicker1.Value; bs.CurrentCond = textBox1.Text; if (type.name.Equals("Bus")) { int psg; if (!int.TryParse(textBox2.Text, out psg)) { return(false); } (bs as Bus).NumOfPassengers = psg; } else if (type.name.Equals("Vagon")) { int psg; if (!int.TryParse(textBox2.Text, out psg)) { return(false); } (bs as Vagon).NumOfPassengers = psg; } else if (type.name.Equals("Voz")) { int psg; if (!int.TryParse(textBox4.Text, out psg)) { return(false); } (bs as Locomotiva).MaximumPulingCapacity = psg; VehicalModel.RemoveVagons(vihecal.Id); for (int i = 0; i < listBox1.Items.Count; i++) { VehicalModel.AddVagon(vihecal.Id, (listBox1.Items[i] as Vagon).Id); } } return(true); }
public static Vehical CreateVehical(eVehicalTypes i_VehicalType, string i_Model, string i_LicensePlate) { Vehical newVehical = null; switch (i_VehicalType) { case eVehicalTypes.ElectricCar: newVehical = new Car(i_Model, i_LicensePlate); newVehical.Engine = new ElectricEngine(EConstants.k_CarMaxBattary); makeCarWheels(newVehical); break; case eVehicalTypes.GasCar: newVehical = new Car(i_Model, i_LicensePlate); newVehical.Engine = new GasEngine(EConstants.k_CarFuelType, EConstants.k_CarMaxGas); makeCarWheels(newVehical); break; case eVehicalTypes.ElectricMotorcycle: newVehical = new Motorcycle(i_Model, i_LicensePlate); newVehical.Engine = new ElectricEngine(EConstants.k_MotorcycleMaxBattary); makeMotorcycleWheels(newVehical); break; case eVehicalTypes.GasMotorcycle: newVehical = new Motorcycle(i_Model, i_LicensePlate); newVehical.Engine = new GasEngine(EConstants.k_MotorcycleFuelType, EConstants.k_MotorcycleMaxGas); makeMotorcycleWheels(newVehical); break; case eVehicalTypes.GasTruck: newVehical = new Truck(i_Model, i_LicensePlate); newVehical.Engine = new GasEngine(EConstants.k_TruckFuelType, EConstants.k_TruckMaxGas); makeTruckWheels(newVehical); break; } return(newVehical); }
// DELETE api/VehicalAPI/5 public HttpResponseMessage DeleteVehical(int id) { Vehical vehical = db.Vehicals.Single(v => v.VehicalID == id); if (vehical == null) { return(Request.CreateResponse(HttpStatusCode.NotFound)); } db.Vehicals.DeleteObject(vehical); try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { return(Request.CreateResponse(HttpStatusCode.NotFound)); } return(Request.CreateResponse(HttpStatusCode.OK, vehical)); }
// PUT api/VehicalAPI/5 public HttpResponseMessage PutVehical(int id, Vehical vehical) { if (ModelState.IsValid && id == vehical.VehicalID) { db.Vehicals.Attach(vehical); db.ObjectStateManager.ChangeObjectState(vehical, System.Data.EntityState.Modified); try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { return(Request.CreateResponse(HttpStatusCode.NotFound)); } return(Request.CreateResponse(HttpStatusCode.OK)); } else { return(Request.CreateResponse(HttpStatusCode.BadRequest)); } }
public void Park(Vehical vehical) { this.vehical = vehical; }
public void Remove(Vehical vehical) { context.Remove(vehical); }
public void Add(Vehical vehical) { context.Add(vehical); }
private static void makeTruckWheels(Vehical i_Vehical) { i_Vehical.Wheels = new List <Wheel>(EConstants.k_TruckWheels); makeWheels(i_Vehical.Wheels, EConstants.k_TruckMaxPsi); }
public static void DoTest(Vehical vehical) { Vehical.Test(); }
private void updateEnergyPercentLeft(Vehical i_Vehical) { i_Vehical.UpdateEnergyPercentLeft(); }
private static void makeMotorcycleWheels(Vehical i_Vehical) { i_Vehical.Wheels = new List <Wheel>(EConstants.k_MotorcycleWheels); makeWheels(i_Vehical.Wheels, EConstants.k_MotorcycleMaxPsi); }