Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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));
        }
Ejemplo n.º 3
0
 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;
     }
 }
Ejemplo n.º 4
0
 public Sistema()
 {
     vehiculos    = new Vehiculos();
     conductores  = new Conductores();
     infracciones = new Infracciones();
 }