コード例 #1
0
        private bool ValidarComprobaciones(ConductorVehiculo conductorVehiculo)
        {
            try
            {
                bool esCorrecto;

                //Check num máximo de conductores habituales
                esCorrecto = ConductorVehiculoService.ComprobarMaxConductores(conductorVehiculo);
                if (!esCorrecto)
                {
                    return(false);
                }

                //Por problema al crear modelo, check si ya existe el conductor en ese vehículo
                esCorrecto = ConductorVehiculoService.ComprobarDuplicidad(conductorVehiculo);
                if (!esCorrecto)
                {
                    return(false);
                }

                return(true);
            }
            catch
            {
                return(false);
            }
        }
コード例 #2
0
        private bool DescontarPuntos(InfraccionVehiculo infraccionVehiculo)
        {
            try
            {
                // Si no ha informado conductor, se busca si solo hay uno habitual
                if (string.IsNullOrEmpty(infraccionVehiculo.dniConductor))
                {
                    infraccionVehiculo.dniConductor = ConductorVehiculoService.ObtenerConductorHabitual(infraccionVehiculo.matricula);
                }

                //Si se ha informado conductor o se ha detectado el habitual, se le restan los puntos
                if (!string.IsNullOrEmpty(infraccionVehiculo.dniConductor))
                {
                    //Se obtienen los puntos a restar de la infracción
                    int puntos = InfraccionesService.ObtenerPuntos(infraccionVehiculo.idInfraccion);

                    //Se devuelve true si se restan los puntos con éxito
                    return(ConductoresService.RestarPuntos(infraccionVehiculo.dniConductor, puntos));
                }

                // No se ha podido asignar el conductor
                return(true);
            }
            catch
            {
                return(false);
            }
        }