//public void InsertData(BasicDetails BasicInfo,string readval) //{ // MongoCollection<BsonDocument> Info = BaseClass.db.GetCollection<BsonDocument>("Basic"); // //Create some data // var movie1 = new Movie { Title = "Indiana Jones and the Raiders of the Lost Ark", Year = "1981" }; // movie1.AddActor("Harrison Ford"); // movie1.AddActor("Karen Allen"); // movie1.AddActor("Paul Freeman"); // Info.Insert(movie1); //} public string InsertBasicDetails(BasicDetails BasicInfo,string rd,string wrt) { string Message; ////////////////////////////////// string [] wordRd=rd.Split(','); string [] wordRw = wrt.Split(','); //string[] terms = { }; //List<String> tmp = new List<string>(); //foreach (string rd1 in words) //{ // tmp.Add(rd1); //} //terms = tmp.ToArray(); MongoCollection<BsonDocument> Info = BaseClass.db.GetCollection<BsonDocument>("Basic"); ////////////////////////////////////////////////////////////////////////////////////////////////////// //var basicdetails = new BasicDetails { basicid = BasicInfo.basicid, name = BasicInfo.Name, description=BasicInfo.Description, expire_t=BasicInfo.Expire_t, expire_s=BasicInfo.Expire_s }; var basicdetails = new BasicDetails { basicid = BasicInfo.basicid, name = BasicInfo.name, description = BasicInfo.description, expire_t = BasicInfo.expire_t, expire_s = BasicInfo.expire_s }; foreach (string rd1 in wordRd){ basicdetails.AddRead(rd1);}foreach (string rd2 in wordRw){basicdetails.AddWrite(rd2);} ///////////////////////////////////////////////////////////////////////////////////////////////////// //BsonDocument Basicdoc = new BsonDocument { // { "basicid", BasicInfo.BasicId }, // { "name", BasicInfo.Name }, // { "description",BasicInfo.Description }, // { "expire_t",BasicInfo.Expire_t }, // { "expire_s",BasicInfo.Expire_s }, // { "read", new BsonArray().Add(BsonValue.Create(rst } }, // { "write", new BsonArray() {terms[cnt] } }, //}; //---------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------- var result = Info.Insert(basicdetails); if (result == null ) { Message = BasicInfo.name + " Details inserted successfully";} else{Message = BasicInfo.name + " Details not inserted successfully";} return Message; }
public string InsertBasicDetails(BasicDetails BasicInfo, string rd, string wrt) { string Message; ////////////////////////////////// string[] wordRd = rd.Split(','); string[] wordRw = wrt.Split(','); MongoCollection<BsonDocument> Info = BaseClass.db.GetCollection<BsonDocument>("Basic"); ////////////////////////////////////////////////////////////////////////////////////////////////////// var dtls = Info.FindOne(Query.EQ("basicid", BasicInfo.basicid)); if (dtls == null) { var basicdetails = new BasicDetails { basicid = BasicInfo.basicid, name = BasicInfo.name, description = BasicInfo.description, expire_t = BasicInfo.expire_t, expire_s = BasicInfo.expire_s }; foreach (string rd1 in wordRd) { basicdetails.AddRead(rd1); } foreach (string rd2 in wordRw) { basicdetails.AddWrite(rd2); } //---------------------------------------------------------------------------------------- var result = Info.Insert(basicdetails); if (result == null) { Message = BasicInfo.name + " Details inserted successfully"; } else { Message = BasicInfo.name + " Details not inserted successfully"; } } else { Message = "Id No. " + BasicInfo.basicid + "is already exist!"; } return Message; }