public static List<RestriccionGeocerca> ConsultarRestricciones(string geocercaID)
 {
     string query = "SELECT * FROM restriccionGeocerca WHERE geocerca = @geocercaID";
     using (SqlConnection sqlConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["connectionStringBD"].ConnectionString))
     {
         sqlConnection.Open();
         using (SqlCommand sqlCommand = new SqlCommand(query,sqlConnection))
         {
             sqlCommand.Parameters.AddWithValue("@geocercaID",geocercaID);
             using (SqlDataReader reader = sqlCommand.ExecuteReader())
             {
                 List<RestriccionGeocerca> restricciones = new List<RestriccionGeocerca>();
                 while (reader.Read())
                 {
                     RestriccionGeocerca restriccion = new RestriccionGeocerca();
                     restriccion.restriccionID = (int)reader["restriccion_id"];
                     restriccion.geocercaID = (string)reader["geocerca"];
                     restriccion.hInicial = (DateTime)reader["FechaHoraInicio"];
                     restriccion.hFinal = (DateTime)reader["fechaHoraFin"];
                     restricciones.Add(restriccion);
                 }
                 return restricciones;
             }
         }
     }
     return null;
 }
 public static bool GuardarRestriccion(RestriccionGeocerca restriccion)
 {
     using (SqlConnection sqlConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["connectionStringBD"].ConnectionString))
     {
         sqlConnection.Open();
         using (SqlTransaction sqlTransaction =  sqlConnection.BeginTransaction())
         {
             try
             {
                 using (SqlCommand sqlCommand = new SqlCommand("RESTRICCION_INSERT_UPDATE",sqlConnection))
                 {
                     sqlCommand.Transaction = sqlTransaction;
                     sqlCommand.CommandType = CommandType.StoredProcedure;
                     sqlCommand.Parameters.AddWithValue("@RELACIONID",restriccion.restriccionID);
                     sqlCommand.Parameters.AddWithValue("@GEOCERCAID",restriccion.geocercaID);
                     sqlCommand.Parameters.AddWithValue("@HINICIAL",restriccion.hInicial);
                     sqlCommand.Parameters.AddWithValue("@HFINAL", restriccion.hFinal);
                     sqlCommand.Parameters.AddWithValue("@VELOCIDAD", 0);//VALOR POR DEFAULT
                     sqlCommand.ExecuteNonQuery();
                     sqlTransaction.Commit();
                     return true;
                 }
             }
             catch (Exception)
             {
                 sqlTransaction.Rollback();
                 throw;
             }
         }
     }
     return false;
 }
    public string GuardarRestriccion(RestriccionGeocerca restricciones)
    {
        HttpCookie Cookie = HttpContext.Current.Request.Cookies.Get("Usuario");
        if (Cookie != null && AutentificacionBD.VerificarToken(Cookie.Values.Get("Token"))) {
            if (GeocercasBD.GuardarRestriccion(restricciones))
                return ConsultarRestricciones(restricciones.geocercaID);
            else
                return "errorBD";

        }
        return "error404";
    }