public void insertData(Stockobject obj)
 {
     JavaScriptSerializer ser = new JavaScriptSerializer();
         string str = ser.Serialize(obj);
         BsonDocument bson = BsonDocument.Parse(str);
         collection.InsertOneAsync(bson);
 }
        public Table createInputs(Stockobject obj)
        {
            System.Web.UI.WebControls.Label lbl1 = new System.Web.UI.WebControls.Label();
            lbl1.Attributes["class"] = "lblDetails";
            lbl1.Text = "Company";
            HtmlGenericControl inpt1 = new HtmlGenericControl("input");
            inpt1.Attributes["type"] = "text";
            inpt1.Attributes["placeholder"] = "Company";
            inpt1.ID = "inpt1" + obj._id;
            inpt1.Attributes["class"] = "input";
            inpt1.Attributes["value"] = obj.Company.ToString();

            System.Web.UI.WebControls.Label lbl2 = new System.Web.UI.WebControls.Label();
            lbl2.Attributes["class"] = "lblDetails";
            lbl2.Text = "Industry";
            HtmlGenericControl inpt2 = new HtmlGenericControl("input");
            inpt2.Attributes["type"] = "text";
            inpt2.Attributes["placeholder"] = "Industry";
            inpt2.ID = "inpt2" + obj._id;
            inpt2.Attributes["class"] = "input";
            inpt2.Attributes["value"] = obj.Industry;

            System.Web.UI.WebControls.Label lbl3 = new System.Web.UI.WebControls.Label();
            lbl3.Attributes["class"] = "lblDetails";
            lbl3.Text = "Volume";
            HtmlGenericControl inpt3 = new HtmlGenericControl("input");
            inpt3.Attributes["type"] = "text";
            inpt3.Attributes["placeholder"] = "Volume";
            inpt3.ID = "inpt3" + obj._id;
            inpt3.Attributes["class"] = "input";
            inpt3.Attributes["value"] = obj.Volume.ToString();

            System.Web.UI.WebControls.Label lbl4 = new System.Web.UI.WebControls.Label();
            lbl4.Attributes["class"] = "lblDetails";
            lbl4.Text = "Country";
            HtmlGenericControl inpt4 = new HtmlGenericControl("input");
            inpt4.Attributes["type"] = "text";
            inpt4.Attributes["placeholder"] = "Country";
            inpt4.ID = "inpt4"+obj._id;
            inpt4.Attributes["class"] = "input";
            inpt4.Attributes["value"] = obj.Country.ToString();

            System.Web.UI.WebControls.Label lbl5 = new System.Web.UI.WebControls.Label();
            lbl5.Attributes["class"] = "lblDetails";
            lbl5.Text = "Sector";
            HtmlGenericControl inpt5 = new HtmlGenericControl("input");
            inpt5.Attributes["type"] = "text";
            inpt5.Attributes["placeholder"] = "Sector";
            inpt5.ID = "inpt5" + obj._id;
            inpt5.Attributes["class"] = "input";
            inpt5.Attributes["value"] = obj.Sector.ToString();

            System.Web.UI.WebControls.Label lbl6 = new System.Web.UI.WebControls.Label();
            lbl6.Attributes["class"] = "lblDetails";
            lbl6.Text = "Ticker";
            HtmlGenericControl inpt6 = new HtmlGenericControl("input");
            inpt6.Attributes["type"] = "text";
            inpt6.Attributes["placeholder"] = "Ticker";
            inpt6.ID = "inpt6" + obj._id;
            inpt6.Attributes["class"] = "input";
            inpt6.Attributes["value"] = obj.Ticker.ToString();

            System.Web.UI.WebControls.Label lbl7 = new System.Web.UI.WebControls.Label();
            lbl7.Attributes["class"] = "lblDetails";
            lbl7.Text = "Price";
            HtmlGenericControl inpt7 = new HtmlGenericControl("input");
            inpt7.Attributes["type"] = "text";
            inpt7.Attributes["placeholder"] = "Price";
            inpt7.ID = "inpt7" + obj._id;
            inpt7.Attributes["class"] = "input";
            inpt7.Attributes["value"] = obj.Price.ToString();

            System.Web.UI.WebControls.Label lbl8 = new System.Web.UI.WebControls.Label();
            lbl8.Attributes["class"] = "lblDetails";
            lbl8.Text = "Volatility (Month)";
            HtmlGenericControl inpt8 = new HtmlGenericControl("input");
            inpt8.Attributes["type"] = "text";
            inpt8.Attributes["placeholder"] = "Volatility (Month)";
            inpt8.ID = "inpt8" + obj._id;
            inpt8.Attributes["class"] = "input";
            inpt8.Attributes["value"] = obj.VolatilityMonth.ToString();

            Table tbl = new Table();
            TableRow row1 = new TableRow();
            TableCell cell11 = new TableCell();
            cell11.Controls.Add(lbl1);
            row1.Controls.Add(cell11);
            TableCell cell12 = new TableCell();
            cell12.Controls.Add(lbl2);
            row1.Controls.Add(cell12);
            TableCell cell13 = new TableCell();
            cell13.Controls.Add(lbl3);
            row1.Controls.Add(cell13);
            TableCell cell14 = new TableCell();
            cell14.Controls.Add(lbl4);
            row1.Controls.Add(cell14);

            tbl.Controls.Add(row1);

            TableRow row2 = new TableRow();
            TableCell cell21 = new TableCell();
            cell21.Controls.Add(inpt1);
            row2.Controls.Add(cell21);
            TableCell cell22 = new TableCell();
            cell22.Controls.Add(inpt2);
            row2.Controls.Add(cell22);
            TableCell cell23 = new TableCell();
            cell23.Controls.Add(inpt3);
            row2.Controls.Add(cell23);
            TableCell cell24 = new TableCell();
            cell24.Controls.Add(inpt4);
            row2.Controls.Add(cell24);

            tbl.Controls.Add(row2);

            TableRow row3 = new TableRow();

            TableCell cell15 = new TableCell();
            cell15.Controls.Add(lbl5);
            row3.Controls.Add(cell15);
            TableCell cell16 = new TableCell();
            cell16.Controls.Add(lbl6);
            row3.Controls.Add(cell16);
            TableCell cell17 = new TableCell();
            cell17.Controls.Add(lbl7);
            row3.Controls.Add(cell17);
            TableCell cell18 = new TableCell();
            cell18.Controls.Add(lbl8);
            row3.Controls.Add(cell18);

            tbl.Controls.Add(row3);

            TableRow row4 = new TableRow();

            TableCell cell25 = new TableCell();
            cell25.Controls.Add(inpt5);
            row4.Controls.Add(cell25);
            TableCell cell26 = new TableCell();
            cell26.Controls.Add(inpt6);
            row4.Controls.Add(cell26);
            TableCell cell27 = new TableCell();
            cell27.Controls.Add(inpt7);
            row4.Controls.Add(cell27);
            TableCell cell28 = new TableCell();
            cell28.Controls.Add(inpt8);
            row4.Controls.Add(cell28);

            tbl.Controls.Add(row4);

            tbl.Attributes["class"] = "tableInpt";
            return tbl;
        }
 public void deleteData(Stockobject obj)
 {
     var collection = database.GetCollection<BsonDocument>("stockCollection");
         var filter = Builders<BsonDocument>.Filter.Eq("Ticker", obj.Ticker);
         collection.DeleteOneAsync(filter);
 }
 public void updateData(Stockobject obj, string _collection)
 {
     JavaScriptSerializer ser = new JavaScriptSerializer();
         var collection = database.GetCollection<BsonDocument>(_collection);
         var filter = Builders<BsonDocument>.Filter.Eq("Ticker", obj.Ticker);
         string str = ser.Serialize(obj);
         BsonDocument bson = BsonDocument.Parse(str);
         collection.UpdateOneAsync(filter, str);
 }