Exemplo n.º 1
0
 //Editing a Vehiculo from de database.
 public override Vehiculo editarVehiculo(Vehiculo vehiculo, Current current)
 {
     using (var scope = _serviceScopeFactory.CreateScope())
     {
         ServerParkingUCNContext pc = scope.ServiceProvider.GetService <ServerParkingUCNContext>();
         pc.Vehiculos.Update(vehiculo);
         pc.SaveChanges();
         return(vehiculo);
     }
     throw new System.NotImplementedException();
 }
Exemplo n.º 2
0
 // Given a patente, returns a vehiculo from Database
 public override Vehiculo obtenerVehiculo(string patente, Current current)
 {
     using (var scope = _serviceScopeFactory.CreateScope())
     {
         ServerParkingUCNContext pc = scope.ServiceProvider.GetService <ServerParkingUCNContext>();
         Vehiculo vehiculo          = pc.Vehiculos.Find(patente);
         pc.SaveChanges();
         return(vehiculo);
     }
     throw new System.NotImplementedException();
 }
Exemplo n.º 3
0
 //Editing a persona from database.
 public override Persona editarPersona(Persona persona, Current current)
 {
     using (var scope = _serviceScopeFactory.CreateScope())
     {
         ServerParkingUCNContext pc = scope.ServiceProvider.GetService <ServerParkingUCNContext>();
         pc.Personas.Update(persona);
         pc.SaveChanges();
         return(persona);
     }
     throw new System.NotImplementedException();
 }
Exemplo n.º 4
0
 //Given a rut, deleting a persona from Database
 public override Persona eliminarPersona(string rut, Current current)
 {
     using (var scope = _serviceScopeFactory.CreateScope())
     {
         ServerParkingUCNContext pc = scope.ServiceProvider.GetService <ServerParkingUCNContext>();
         Persona persona            = pc.Personas.Find(rut);
         pc.Personas.Remove(persona);
         pc.SaveChanges();
         return(persona);
     }
     throw new System.NotImplementedException();
 }
Exemplo n.º 5
0
        //Method that accounts and returns the statistics of the application
        public override int datosEstadisticos(string busquedaDato, Current current)
        {
            using (var scope = _serviceScopeFactory.CreateScope())
            {
                ServerParkingUCNContext pc = scope.ServiceProvider.GetService <ServerParkingUCNContext>();
                int dato = pc.Personas.Where(w => w.unit == busquedaDato).Count();
                pc.SaveChanges();

                return(dato);
            }
            throw new System.NotImplementedException();
        }
Exemplo n.º 6
0
        //Method that accounts for people in a certain region
        public override int totalRegion(string region, Current current)
        {
            using (var scope = _serviceScopeFactory.CreateScope())
            {
                ServerParkingUCNContext pc = scope.ServiceProvider.GetService <ServerParkingUCNContext>();
                int dato = pc.Personas.Where(w => w.country == region).Count();
                pc.SaveChanges();

                return(dato);
            }
            throw new System.NotImplementedException();
        }
Exemplo n.º 7
0
        //Method that returns the door of access and exit of the vehicle
        public override int  vehiculosGate(string puerta, Current current)
        {
            using (var scope = _serviceScopeFactory.CreateScope())
            {
                ServerParkingUCNContext pc = scope.ServiceProvider.GetService <ServerParkingUCNContext>();
                string fecha = DateTime.Now.ToString("dd-M-yyyy");
                int    dato  = pc.Circulaciones.Where(w => w.estadoVehiculo == 1).Where(p => p.puertaEntrada == puerta).Where(w => w.fechaIngreso == fecha).Count();
                pc.SaveChanges();

                return(dato);
            }
            throw new System.NotImplementedException();
        }
Exemplo n.º 8
0
 //Method that searches for a vehicle entered in the university
 public override Circulacion busquedaVehiculoBackend(string patente, Current current)
 {
     using (var scope = _serviceScopeFactory.CreateScope())
     {
         int estado = 1;
         ServerParkingUCNContext pc     = scope.ServiceProvider.GetService <ServerParkingUCNContext>();
         Circulacion             salida = new Circulacion();
         salida = pc.Circulaciones.Where(w => w.patente == patente).Where(a => a.estadoVehiculo == estado).FirstOrDefault();
         pc.SaveChanges();
         return(salida);
     }
     throw new System.NotImplementedException();
 }
Exemplo n.º 9
0
        ///<sumary>
        /// The Constructor
        ///</sumary>
        ///<param name="logger">The Logger</param>
        ///<param name="serviceScopeFactory">The Scope</param>
        public TheSystemImpl(ILogger <TheSystemImpl> logger, IServiceScopeFactory serviceScopeFactory)
        {
            _logger = logger;
            _logger.LogDebug("Building TheSystemImpl ..");
            _serviceScopeFactory = serviceScopeFactory;

            // Create the database
            _logger.LogInformation("Creating the Database ..");
            using (var scope = _serviceScopeFactory.CreateScope())
            {
                ServerParkingUCNContext pc = scope.ServiceProvider.GetService <ServerParkingUCNContext>();
                pc.Database.EnsureCreated();
                pc.SaveChanges();
            }
        }
Exemplo n.º 10
0
 //Method that records the departure of the vehicle
 public override Circulacion salidaVehiculo(string patente, string puertaSalida, Current current)
 {
     using (var scope = _serviceScopeFactory.CreateScope())
     {
         var dato = 0;
         ServerParkingUCNContext pc     = scope.ServiceProvider.GetService <ServerParkingUCNContext>();
         Circulacion             salida = new Circulacion();
         salida = pc.Circulaciones.Where(w => w.patente == patente).Where(a => a.estadoVehiculo == 1).FirstOrDefault();
         salida.puertaSalida   = puertaSalida;
         salida.estadoVehiculo = dato;
         salida.fechaSalida    = DateTime.Now.ToString("dd-M-yyyy");
         salida.horaSalida     = DateTime.Now.ToString("HH:mm:ss");
         pc.SaveChanges();
         return(salida);
     }
     throw new System.NotImplementedException();
 }
Exemplo n.º 11
0
 //Method that records the entry of the vehicle
 public override Circulacion ingresoVehiculo(string patente, string puertaEntrada, string observacion, Current current)
 {
     using (var scope = _serviceScopeFactory.CreateScope())
     {
         var dato = 1;
         ServerParkingUCNContext pc      = scope.ServiceProvider.GetService <ServerParkingUCNContext>();
         Circulacion             ingreso = new Circulacion();
         ingreso.patente        = patente;
         ingreso.puertaEntrada  = puertaEntrada;
         ingreso.estadoVehiculo = dato;
         ingreso.observacion    = observacion;
         ingreso.fechaIngreso   = DateTime.Now.ToString("dd-M-yyyy");
         ingreso.horaIngreso    = DateTime.Now.ToString("HH:mm:ss");
         pc.Circulaciones.Add(ingreso);
         pc.SaveChanges();
         return(ingreso);
     }
     throw new System.NotImplementedException();
 }
Exemplo n.º 12
0
        // Adds a Vehiculo to Database
        public override Vehiculo registrarVehiculo(Vehiculo vehiculo, Current current = null)
        {
            try {
                using (var scope = _serviceScopeFactory.CreateScope())
                {
                    ServerParkingUCNContext pc = scope.ServiceProvider.GetService <ServerParkingUCNContext>();
                    pc.Vehiculos.Add(vehiculo);
                    pc.SaveChanges();
                    return(vehiculo);
                }
            }

            catch (SqliteException exception) {
                _logger.LogDebug("Error: : {}", exception.InnerException);
                return(null);
            }
            catch (Exception exception)
            {
                _logger.LogDebug("Error de servidor : {}", exception.InnerException);
                throw new  NullReferenceException("Error interno del servidor");
            }
        }