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; + } } }