Example #1
0
        internal List <getData> SearchByData(getData gd)
        {
            //declares MongoDB Collection
            MongoCollection <getData> collection = GetDataCollection();

            //ttt equals the collection queried and gets the relevant data
            var ttt = (from p in collection.AsQueryable()
                       where p.username.ToUpper().Contains(gd.username.ToUpper())
                       select new // selects the data found
            {
                p.username,
                p.Id,
                p.latitude,
                p.longitude,
                p.imageUploaded,
                p.lastComment
            });
            //declares list to fill the data
            List <getData> list = new List <getData>();

            foreach (var t2 in ttt)
            {
                //adds to list the data equalling to the getData variables
                list.Add(new getData {
                    Id            = t2.Id,
                    username      = t2.username,
                    latitude      = t2.latitude,
                    longitude     = t2.longitude,
                    imageUploaded = t2.imageUploaded,
                    lastComment   = t2.lastComment
                });
            }
            //returns the data in a list
            return(list);
        }
        public void insertNoSQL()
        {
            //decalre variable to parse
            double lat;
            double lon;

            //parses the textbox variables to double
            lat = double.Parse(txtLatitude.Text);
            lon = double.Parse(txtLongitude.Text);

            //declare forms
            dal     d  = new dal();
            getData gd = new getData
            {
                //sets variables from getData
                username      = txtUsername.Text,
                latitude      = lat,
                longitude     = lon,
                imageUploaded = txtURL.Text,
                lastComment   = txtComment.Text
            };

            //calls Create record from dal using the data set from getData
            d.CreateRecord(gd);
            txtUsername.Text  = txtUsername.Text;
            txtLatitude.Text  = "";
            txtLongitude.Text = "";
            txtURL.Text       = "";
            txtComment.Text   = "";
        }
Example #3
0
        public void display_NosqlData()
        {
            //method to collect data from NoSQL database
            getData gd = new getData
            {
                username = txtUsername.Text + ""
            }; // retrieves data containing the username entered
            dal            d    = new dal();
            List <getData> list = d.SearchByData(gd);

            //calls method to generate a list of data from the NoSQL database
            dataGridViewNosql.DataSource = list;
        }
Example #4
0
        // Creates a record and inserts it into the collection in MongoDB.
        public void CreateRecord(getData data)
        {
            //declares collection
            MongoCollection <getData> collection = GetDataCollection();

            try
            {
                //inserts the new document in MongoDB database
                //.Insert = MongoCollection commmand
                collection.Insert(data);
            }
            catch (MongoCommandException ex)
            {
                string msg = ex.Message;
            }
        }