public ActionResult Editar(Conductor pData) { Conductores conductores = new Conductores(); conductores.guardar(pData, "INS"); return(View(conductores)); }
public IHttpActionResult PostConductores(Conductores conductores) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.Conductores.Add(conductores); try { db.SaveChanges(); } catch (DbUpdateException) { if (ConductoresExists(conductores.dni)) { return(Conflict()); } else { throw; } } return(CreatedAtRoute("DefaultApi", new { id = conductores.dni }, conductores)); }
public async Task <IActionResult> PutConductores(int id, Conductores conductores) { if (id != conductores.Id) { return(BadRequest()); } _context.Entry(conductores).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ConductoresExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public Vehiculo CrearVehiculo(String matricula, String marca, String modelo, string dni) { try { //Si existe matricula ERROR if (ExisteMatricula(matricula)) { throw new Exception("Matricula Existe"); } //Si no existe dni ERROR Conductor c = Conductores.Where(x => x.DNI == dni).First(); if (c == null) { throw new Exception("DNI no Existe"); } Vehiculo v = new Vehiculo(matricula, marca, modelo); //La descripcion no especifica si el conductor ya es habitual 10 veces, si el vehiculo se añade(sin conductor) o no. //Yo decido añadirlo solo si puede ser habital if (AñadirConductorHabitual(v, c)) { Vehiculos.Add(v); return(v); } return(null); } catch (Exception e) { throw e; } }
public ActionResult VerDatos(int id) { Conductores conductores = new Conductores(); Conductor obj = conductores.getConductor(id); var model = obj; return(View(obj)); }
public ActionResult Editar(int id) { Conductores conductores = new Conductores(); Conductor obj = conductores.getConductor(id); var modek = obj; return(View(obj)); }
private bool ExisteDNI(String dni) { if (Conductores.Any(x => x.DNI == dni)) { return(true); } return(false); }
public ActionResult Listar() { ViewBag.Message = "Listado de Conductores"; Conductores ldata = new Conductores(); ldata.buscar("*", ""); var model = ldata.getData(); return(View(model)); }
static public Conductores GetConductor(string dni) { try { Conductores oConductor = db.Conductores .Where(x => x.dni == dni) .First(); return(oConductor); } catch { return(null); } }
public List <InfraccionesConductor> GetInfraccionConductor(string id) { try { Conductores oConductor = ConductoresService.GetConductor(id); List <InfraccionesConductor> liInfCond = InformarListaInfraccionesConductor(oConductor); return(liInfCond); } catch { return(null); } }
public Conductor CreateConductor(String dni, String nombre, String apellidos) { if (ExisteDNI(dni)) { return(null); } try { Conductor c = new Conductor(dni, nombre, apellidos); Conductores.Add(c); return(c); } catch (Exception e) { throw e; } }
static public bool RestarPuntos(string dni, int puntos) { try { Conductores oConductor = db.Conductores .Where(x => x.dni == dni) .First(); oConductor.puntos -= puntos; db.SaveChanges(); return(true); } catch { return(false); } }
public async Task <ActionResult <Conductores> > PostConductores(Conductores conductores) { _context.Conductores.Add(conductores); try { await _context.SaveChangesAsync(); } catch (DbUpdateException) { if (ConductoresExists(conductores.Id)) { return(Conflict()); } else { throw; } } return(CreatedAtAction("GetConductores", new { id = conductores.Id }, conductores)); }
// ----------------- Métodos auxiliares------------- #region Métodos auxiliares private List <InfraccionesConductor> InformarListaInfraccionesConductor(Conductores oConductor) { try { List <InfraccionesConductor> liInfCond = new List <InfraccionesConductor>(); foreach (InfraccionVehiculo oInfVeh in oConductor.InfraccionVehiculo) { InfraccionesConductor oInfCond = new InfraccionesConductor(oConductor.nombre, oConductor.dni, oInfVeh.Infracciones.descripcion, oInfVeh.fecha); liInfCond.Add(oInfCond); return(liInfCond); } return(null); } catch { return(null); } }
public bool RegistrarInfraccion(Infraccion i, Vehiculo v) { try { Conductor c = Conductores.Where(x => x.DNI == v.ConductoresHabituales.First().DNI).First(); if (c != null) { InfraccionRegistrada ir = new InfraccionRegistrada() { Matricula = v.Matricula, Dni = c.DNI, Fecha = DateTime.Now, Infraccion = i }; c.DescontarPuntos(i.PuntosDescontar); InfraccionesRegistradas.Add(ir); return(true); } return(false); } catch (Exception e) { throw e; } }
public ConductorController() { m_regs = new Conductores(); }
public Sistema() { vehiculos = new Vehiculos(); conductores = new Conductores(); infracciones = new Infracciones(); }