void addScooters() { Console.WriteLine(); Console.WriteLine("ADDING SCOOTERS..."); try { // public Scooter(DateTime registerDate, ScooterState state) Scooter sc = new Scooter(Convert.ToDateTime("01/10/2019"), ScooterState.available); service.registerScooter(sc); Station st = service.findStationById("st1"); st.assignScooter(sc); service.saveChanges(); sc = new Scooter(Convert.ToDateTime("01/10/2019"), ScooterState.available); service.registerScooter(sc); st.assignScooter(sc); service.saveChanges(); sc = new Scooter(Convert.ToDateTime("01/10/2019"), ScooterState.available); service.registerScooter(sc); st.assignScooter(sc); service.saveChanges(); sc = new Scooter(Convert.ToDateTime("01/10/2019"), ScooterState.inMaintenance); service.registerScooter(sc); st.assignScooter(sc); service.saveChanges(); } catch (Exception e) { printError(e); } foreach (Scooter s in service.getAllScooters()) { Console.WriteLine(scooterToString(s)); } }
private void button1_Click(object sender, EventArgs e) { Boolean err = false; string mens = ""; string est = ""; try { if (txt_estacion.TextLength == 0) { err = true; mens += "El campo Estación es obligatorio \n"; } else { est = txt_estacion.Text; } if (btn_disponible.Checked == true) { estado = ScooterState.available; } if (btn_mantenimiento.Checked == true) { estado = ScooterState.inMaintenance; } if (btn_disponible.Checked == false & btn_mantenimiento.Checked == false) { err = true; mens += "Elige una de las opciones en la sección del Estado \n"; } if (!err) { DialogResult answer = MessageBox.Show(this, "Patinete agregado \n", "Well done", MessageBoxButtons.OK, MessageBoxIcon.Information); if (answer == DialogResult.OK) { Scooter sc = new Scooter(txt_fecha.Value.Date, estado); service.registerScooter(sc); Station st = service.findStationById(est); st.assignScooter(sc); service.saveChanges(); this.Close(); } } else { DialogResult answer = MessageBox.Show(this, "Revise los datos introducidos \n" + mens, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch (ServiceException ex) { MessageBox.Show(ex.Message); } }