From e681580d2df3251a0f67dc818b25bf3359fc70ad Mon Sep 17 00:00:00 2001 From: Argo-MacBookPro Date: Wed, 31 Oct 2018 17:32:19 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=8A=9F=E8=83=BD=EF=BC=9A?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=BF=9D=E5=AD=98=E5=AD=97=E5=85=B8=E6=96=B9?= =?UTF-8?q?=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Bootstrap.DataAccess.MongoDB/Dict.cs | 35 ++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/Bootstrap.DataAccess.MongoDB/Dict.cs b/Bootstrap.DataAccess.MongoDB/Dict.cs index e1aa4d11..0659a42f 100644 --- a/Bootstrap.DataAccess.MongoDB/Dict.cs +++ b/Bootstrap.DataAccess.MongoDB/Dict.cs @@ -15,6 +15,7 @@ namespace Bootstrap.DataAccess.MongoDB /// /// public override IEnumerable RetrieveDicts() => MongoDbAccessManager.Dicts.Find(FilterDefinition.Empty).ToList(); + /// /// /// @@ -30,5 +31,39 @@ namespace Bootstrap.DataAccess.MongoDB MongoDbAccessManager.Dicts.BulkWrite(list); return true; } + + /// + /// + /// + /// + /// + public override bool SaveDict(BootstrapDict p) + { + if (p.Id == "0") + { + p.Id = null; + MongoDbAccessManager.Dicts.InsertOne(p); + return true; + } + else + { + MongoDbAccessManager.Dicts.UpdateOne(md => md.Id == p.Id, Builders.Update.Set(md => md.Category, p.Category) + .Set(md => md.Define, p.Define) + .Set(md => md.Name, p.Name) + .Set(md => md.Code, p.Code)); + return true; + } + } + + /// + /// + /// + /// + /// + public override bool SaveSettings(BootstrapDict dict) + { + MongoDbAccessManager.Dicts.FindOneAndUpdate(md => md.Category == dict.Category && md.Name == dict.Name, Builders.Update.Set(md => md.Code, dict.Code)); + return true; + } } }