public ExcesosDatamart GetExcesos(DateTime from, DateTime to) { var excesos = new ExcesosDatamart(); if (Infracciones.Count().Equals(0)) { return(excesos); } var infractions = Infracciones.Where(infraction => infraction.Fecha >= from && infraction.Fecha <= to).ToList(); if (!infractions.Any()) { return(excesos); } foreach (var infraction in infractions) { excesos.Excesos += 1; excesos.SegundosExceso += infraction.Duracion.TotalSeconds; } Infracciones = Infracciones.Where(infraction => infraction.Fecha > to).ToList(); return(excesos); }
public IHttpActionResult PostInfracciones(Infracciones infracciones) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.Infracciones.Add(infracciones); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = infracciones.id }, infracciones)); }
public Infraccion NuevaInfraccion(string identificador, string descripción, int puntos) { try { //Si existe la infraccion if (Infracciones.Exists(X => X.Identificador == identificador)) { return(null); } Infraccion i = new Infraccion() { Identificador = identificador, Descripcion = descripción, PuntosDescontar = puntos }; Infracciones.Add(i); return(i); } catch (Exception e) { throw e; } }
public Sistema() { vehiculos = new Vehiculos(); conductores = new Conductores(); infracciones = new Infracciones(); }