public ActionResult Add(MasterMobileModel mstrMobile) { if (ModelState.IsValid) { var Client = new MongoClient(constr); var DB = Client.GetDatabase(databaseName); var collection = DB.GetCollection <MasterMobileModel>("tMasterMobile"); mstrMobile._id = ObjectId.GenerateNewId(); mstrMobile.id = new Sequence() { }.GetNextSequenceValue("tMasterMobile", databaseName); mstrMobile.crtAt = GlobalFunctions.GetIPAddress(); mstrMobile.crtBy = "Luthfi"; mstrMobile.crtOn = DateTime.Now; mstrMobile.expired = DateTime.Now.AddHours(3); mstrMobile.shnEndDate = DateTime.Now.AddDays(14); collection.InsertOneAsync(mstrMobile); return(RedirectToAction("index")); } return(View()); }
public ActionResult Edit(string id, MasterMobileModel MstrMobileDet) { try { var client = new MongoClient(constr); var db = client.GetDatabase(databaseName); var collection = db.GetCollection <MasterMobileModel>("tMasterMobile"); var filter = Builders <MasterMobileModel> .Filter.Eq("id", id); MstrMobileDet.uptAt = GlobalFunctions.GetIPAddress(); MstrMobileDet.uptBy = "User"; MstrMobileDet.uptOn = DateTime.Now; var set = Builders <MasterMobileModel> .Update .Set("id", MstrMobileDet.id) .Set("mstMblNo", MstrMobileDet.mstMblNo) .Set("mstMblCtrCd", MstrMobileDet.mstMblCtrCd) .Set("mstPosCode", MstrMobileDet.mstPosCode) .Set("otpMode", MstrMobileDet.otpMode) .Set("act", MstrMobileDet.act) .Set("otp", MstrMobileDet.otp) .Set("email", MstrMobileDet.email) .Set("expired", MstrMobileDet.expired) .Set("shnEndDate", MstrMobileDet.shnEndDate) .Set("uptOn", MstrMobileDet.uptOn) .Set("uptAt", MstrMobileDet.uptAt) .Set("uptBy", MstrMobileDet.uptBy); collection.FindOneAndUpdateAsync(filter, set); return(RedirectToAction("index")); } catch (Exception ex) { return(View()); } }
public ActionResult Editing_Destroy([DataSourceRequest] DataSourceRequest request, MasterMobileModel masterMobile) { if (masterMobile != null) { var client = new MongoClient(constr); var db = client.GetDatabase(databaseName); var collection = db.GetCollection <MasterMobileModel>("tMasterMobile"); var filter = Builders <MasterMobileModel> .Filter.Eq("id", masterMobile.id); var deleteRecord = collection.DeleteOneAsync(filter); } return(Json(new[] { masterMobile }.ToDataSourceResult(request, ModelState))); }
public ActionResult Editing_Update([DataSourceRequest] DataSourceRequest request, MasterMobileModel masterMobile) { var Client = new MongoClient(constr); var DB = Client.GetDatabase(databaseName); if (masterMobile != null && ModelState.IsValid) { var collection = DB.GetCollection <MasterMobileModel>("tMasterMobile"); var filter = Builders <MasterMobileModel> .Filter.Eq("_id", masterMobile._id); masterMobile.uptAt = GlobalFunctions.GetIPAddress(); masterMobile.uptBy = "User"; masterMobile.uptOn = DateTime.Now; var set = Builders <MasterMobileModel> .Update .Set("id", masterMobile.id) .Set("mstMblNo", masterMobile.mstMblNo) .Set("mstMblCtrCd", masterMobile.mstMblCtrCd) .Set("mstPosCode", masterMobile.mstPosCode) .Set("otpMode", masterMobile.otpMode) .Set("act", masterMobile.act) .Set("otp", masterMobile.otp) .Set("email", masterMobile.email) .Set("expired", masterMobile.expired) .Set("shnEndDate", masterMobile.shnEndDate) .Set("uptOn", masterMobile.uptOn) .Set("uptAt", masterMobile.uptAt) .Set("uptBy", masterMobile.uptBy); collection.FindOneAndUpdateAsync(filter, set); } return(Json(new[] { masterMobile }.ToDataSourceResult(request, ModelState))); }
public ActionResult Editing_Create([DataSourceRequest] DataSourceRequest request, MasterMobileModel masterMobile) { var Client = new MongoClient(constr); var DB = Client.GetDatabase(databaseName); if (masterMobile != null && ModelState.IsValid) { var collection = DB.GetCollection <MasterMobileModel>("tMasterMobile"); masterMobile._id = ObjectId.GenerateNewId(); masterMobile.id = new Sequence() { }.GetNextSequenceValue("tMasterMobile", databaseName); masterMobile.crtAt = GlobalFunctions.GetIPAddress(); masterMobile.crtBy = "Luthfi"; masterMobile.crtOn = DateTime.Now; masterMobile.expired = DateTime.Now.AddHours(3); masterMobile.shnEndDate = DateTime.Now.AddDays(14); collection.InsertOneAsync(masterMobile); } return(Json(new[] { masterMobile }.ToDataSourceResult(request, ModelState))); }