// Creates a Note and inserts it into the collection in MongoDB.
 public void CreateNote(Note note)
 {
     MongoCollection<Note> collection = GetNotesCollectionForEdit();
     try
     {
         collection.Insert(note);
     }
     catch (MongoCommandException ex)
     {
         // ReSharper disable once UnusedVariable
         string msg = ex.Message;
     }
 }
        public List<Note> GetNotes()
        {
            //var stopwatch = new Stopwatch();
            //stopwatch.Start();
            List<Note> lista = new List<Note>();

            using (SqlConnection conn = new SqlConnection(DatosConexion))
            {
                string sql = @"SELECT * FROM Note";

                SqlCommand command = new SqlCommand(sql, conn);

                conn.Open();

                SqlDataReader reader = command.ExecuteReader();

                if (reader.Read())
                {
                    Note nota;
                    foreach (var valor in reader)
                    {
                        nota = new Note
                        {
                            Id = Guid.Parse(reader["Id"].ToString()),
                            Text = Convert.ToString(reader["Note"]),
                            Date = Convert.ToDateTime(reader["Date"])
                        };

                        lista.Add(nota);
                    }
                }
                //stopwatch.Stop();
                //Console.WriteLine("Tiempo Transcurrido" + stopwatch.ElapsedMilliseconds);
                return lista;
            }
        }
        public void CreateSQlNote(Note note)
        {
            //var stopwatch = new Stopwatch();
            //stopwatch.Start();
            using (SqlConnection con = new SqlConnection(DatosConexion))
            {
                //Paso 2 - Abrir la conexión
                con.Open();

                // Paso 3 - Crear un nuevo comando

                const string textoCmd = "Insert into Note (Note, Date) values(@note, @datetime);";

                try
                {
                    SqlCommand cmd = new SqlCommand(textoCmd, con);
                    //cmd.Parameters.AddWithValue("@id", note.Id);
                    cmd.Parameters.AddWithValue("@note", note.Text);
                    cmd.Parameters.AddWithValue("datetime", note.Date);

                    //Paso 4 - Ejecutar el comando

                    cmd.ExecuteNonQuery();

                    con.Close();

                }
                catch (Exception e)
                {
                    throw new Exception(e.Message);
                }
            }

            //stopwatch.Stop();
            //Console.WriteLine("Tiempo Transcurrido" + stopwatch.ElapsedMilliseconds);
        }