示例#1
0
        public string UpdateDocument(AdminData adminData)
        {
            try
            {
                MongoDatabase myDB = GetDB();

                MongoCollection <AdminData> adminDataTable = myDB.GetCollection <AdminData>("AdminData");

                QueryDocument queryDoc = new QueryDocument("_id", adminData._id);

                IMongoQuery query = queryDoc;

                //    IMongoUpdate update = new UpdateDocument("Address","Hyd");

                //  IMongoUpdate update = new UpdateDocument().Set("Address", "Hyd") as UpdateDocument;

                //   IMongoUpdate update = new UpdateDocument().Set(queryDoc.IndexOfName("Address"), "Hyd") as UpdateDocument;

                var updateDoc = Update.Set("Address", adminData.Address).Set("Age", adminData.Age.ToString()).Set("Name", adminData.Name).Set("SlNo", adminData.SlNo.ToString());

                IMongoUpdate update = updateDoc;

                WriteConcernResult updateResult = adminDataTable.Update(query, update);

                return("Succcess");
                //  adminDataTable.Update()

                // GetCollection();
            }
            catch (Exception ex)
            {
                throw;
            }
        }
示例#2
0
        private void UpdateDoc()
        {
            AdminData admindata = grdcAdminData.GetFocusedRow() as AdminData;

            if (!string.IsNullOrEmpty(repo.UpdateDocument(admindata)))
            {
                GetDocs();
            }
        }
示例#3
0
        private void DeleteDoc()
        {
            AdminData recordToDelete = grdcAdminData.GetFocusedRow() as AdminData;

            if (!string.IsNullOrEmpty(repo.DeleteDocument(recordToDelete._id)))
            {
                GetDocs();
            }
        }
示例#4
0
        public string InsertDocument(AdminData adminData)
        {
            try
            {
                MongoDatabase myDB = GetDB();

                MongoCollection <AdminData> adminDataTable = myDB.GetCollection <AdminData>("AdminData");

                adminDataTable.Insert(adminData);

                return("Succcess");
            }
            catch (Exception ex)
            {
                throw;
            }
        }
示例#5
0
        private void btnAdd_Click(object sender, RoutedEventArgs e)
        {
            AdminData adminData = new AdminData();

            adminData._id = ObjectId.GenerateNewId();

            adminData.Name = teName.Text;

            adminData.SlNo = Convert.ToInt32(tcSlno.Text);

            adminData.Age = Convert.ToInt32(teAge.Text);

            adminData.Address = teAddress.Text;

            Entity = adminData;

            this.DialogResult = true;
        }
示例#6
0
        public List<AdminData> GetCollection()
        {
            try
            {
                List<AdminData> adminDataList = new List<AdminData>();

                MongoDatabase myDB = GetDB();

                MongoCollection<AdminData> adminDataTable = myDB.GetCollection<AdminData>("AdminData");

                MongoCursor<BsonDocument> cursor = adminDataTable.FindAllAs<BsonDocument>();

                foreach (var item in cursor)
                {
                    AdminData admnData = new AdminData();

                    admnData._id = (ObjectId)item["_id"];

                    admnData.Address = item["Address"].ToString();

                    admnData.Name = item["Name"].ToString();

                    admnData.Age = Convert.ToInt32(item["Age"].ToString());

                    admnData.SlNo = Convert.ToInt32(item["SlNo"].ToString());

                    adminDataList.Add(admnData);
                }

               // grdcAdminData.ItemsSource = adminDataList;

                return adminDataList;
            }
            catch (Exception ex)
            {
                throw;
            }
        }
示例#7
0
        public List <AdminData> GetCollection()
        {
            try
            {
                List <AdminData> adminDataList = new List <AdminData>();

                MongoDatabase myDB = GetDB();

                MongoCollection <AdminData> adminDataTable = myDB.GetCollection <AdminData>("AdminData");

                MongoCursor <BsonDocument> cursor = adminDataTable.FindAllAs <BsonDocument>();

                foreach (var item in cursor)
                {
                    AdminData admnData = new AdminData();

                    admnData._id = (ObjectId)item["_id"];

                    admnData.Address = item["Address"].ToString();

                    admnData.Name = item["Name"].ToString();

                    admnData.Age = Convert.ToInt32(item["Age"].ToString());

                    admnData.SlNo = Convert.ToInt32(item["SlNo"].ToString());

                    adminDataList.Add(admnData);
                }

                // grdcAdminData.ItemsSource = adminDataList;

                return(adminDataList);
            }
            catch (Exception ex)
            {
                throw;
            }
        }
示例#8
0
        public string InsertDocument(AdminData adminData)
        {
            try
            {

                MongoDatabase myDB = GetDB();

                MongoCollection<AdminData> adminDataTable = myDB.GetCollection<AdminData>("AdminData");

                adminDataTable.Insert(adminData);

                return "Succcess";
            }
            catch (Exception ex)
            {
                throw;
            }
        }
示例#9
0
        public string UpdateDocument(AdminData adminData)
        {
            try
            {
                MongoDatabase myDB = GetDB();

                MongoCollection<AdminData> adminDataTable = myDB.GetCollection<AdminData>("AdminData");

                QueryDocument queryDoc = new QueryDocument("_id", adminData._id);

                IMongoQuery query = queryDoc;

                //    IMongoUpdate update = new UpdateDocument("Address","Hyd");

                //  IMongoUpdate update = new UpdateDocument().Set("Address", "Hyd") as UpdateDocument;

                //   IMongoUpdate update = new UpdateDocument().Set(queryDoc.IndexOfName("Address"), "Hyd") as UpdateDocument;

                var updateDoc = Update.Set("Address", adminData.Address).Set("Age",adminData.Age.ToString()).Set("Name",adminData.Name).Set("SlNo",adminData.SlNo.ToString());

                IMongoUpdate update = updateDoc;

                WriteConcernResult updateResult = adminDataTable.Update(query, update);

                return "Succcess";
                //  adminDataTable.Update()

                // GetCollection();
            }
            catch (Exception ex)
            {
                throw;
            }
        }