Esempio n. 1
0
        public Notice Enregistrer()
        {
            Notice notice = GetNotice();

            if (notice != null)
            {
                if (notice.exemplaires == null)
                {
                    notice.exemplaires = new List <Exemplaire>();
                }
                //if (notice.exemplaires.Count == 0)
                //    notice.exemplaires.Add(new Exemplaire() { _id = MongoDB.Bson.ObjectId.GenerateNewId(), codeBarre = notice.isbn, localisation = Properties.Settings.Default.Localisation });

                var coll = new MongoDB.Driver.MongoClient(Properties.Settings.Default.MongoDB).GetDatabase("wfBiblio").GetCollection <Notice>("Notice");
                if (notice._id == ObjectId.Empty)
                {
                    coll.InsertOne(notice);
                }
                else
                {
                    coll.ReplaceOne(a => a._id == notice._id, notice, new ReplaceOptions()
                    {
                        IsUpsert = true
                    });
                }
                if (desherbages.Count > 0)
                {
                    var coll2 = new MongoDB.Driver.MongoClient(Properties.Settings.Default.MongoDB).GetDatabase("wfBiblio").GetCollection <Desherbage>("Desherbage");
                    coll2.InsertMany(desherbages);
                    desherbages.Clear();
                }
            }
            return(notice);
        }
Esempio n. 2
0
        public void Enregistrer()
        {
            Notice notice = GetNotice();

            if (notice != null)
            {
                var coll = new MongoDB.Driver.MongoClient(Properties.Settings.Default.MongoDB).GetDatabase("wfBiblio").GetCollection <Notice>("Notice");
                coll.ReplaceOne(Builders <Notice> .Filter.Eq(a => a._id, notice._id), notice);
            }
        }
Esempio n. 3
0
        private void btnEnregistrerNotice_Click(object sender, EventArgs e)
        {
            Notice notice = ctrlNotices1.GetNotice();

            if (notice != null)
            {
                var coll = new MongoDB.Driver.MongoClient(Properties.Settings.Default.MongoDB).GetDatabase("wfBiblio").GetCollection <Notice>("Notice");
                coll.ReplaceOne(Builders <Notice> .Filter.Eq(a => a._id, notice._id), notice);
            }
        }