Exemplo n.º 1
0
        protected void search_Click(object sender, EventArgs e)
        {
            string pId = txt_search_pilgrim.Text;

            //var client = new MongoClient("mongodb://localhost:27017");
            //var database = client.GetDatabase("hajjhackathon");
            //var pilgrimColl = database.GetCollection<BsonDocument>("Pilgrim");
            //var filter = Builders<BsonDocument>.Filter.Eq("pilgrimId", pId);
            //var document = pilgrimColl.Find(filter).First();

            overridePageLoad = true;

            BsonDocument document = operations.findPilgrim(pId);

            if (document != null)
            {
                fullName.Text    = document["fullName"].AsString;
                pilgrimId.Text   = document["pilgrimId"].AsString;
                userId.Text      = document["userId"].AsString;
                nationality.Text = document["nationality"].AsString;
                residency.Text   = document["residency"].AsString;
                credit.Text      = document["HCredit"].AsDouble.ToString();
                phone.Text       = document["phone"].AsString;

                Session["adminPilgrimID"] = pilgrimId.Text;

                // get transactions

                List <transactions> tr = operations.getTransactions(pId);

                if (tr != null)
                {
                    gvTransactions.DataSource = tr;
                    gvTransactions.DataBind();
                }
                else
                {
                    Label lb = new Label();
                    lb.Text = "There are no transactions for this pilgrim";
                    noTransactions.Controls.Add(lb);
                }

                //if (tr != null)
                //{
                //    foreach (var item in tr)
                //    {

                //    }
                //}
                //else
                //{
                //    // no transactions
                //}



                // this should be in another method, but for now keep it here
                BsonDocument oldPilgrimInfo = operations.findPilgrim(pId);

                txt_edit_fullName.Text    = oldPilgrimInfo["fullName"].AsString;
                txt_edit_pilgrimId.Text   = oldPilgrimInfo["pilgrimId"].AsString;
                txt_edit_userId.Text      = oldPilgrimInfo["userId"].AsString;
                txt_edit_nationality.Text = oldPilgrimInfo["nationality"].AsString;
                txt_edit_residency.Text   = oldPilgrimInfo["residency"].AsString;
                txt_edit_credit.Text      = oldPilgrimInfo["HCredit"].AsDouble.ToString();
                txt_edit_phone.Text       = oldPilgrimInfo["phone"].AsString;
            }
            else
            {
                // no pilgrim with this id
            }
        }