增加功能:增加保存字典方法

This commit is contained in:
Argo-MacBookPro 2018-10-31 17:32:19 +08:00
parent 99a8b5432d
commit e681580d2d
1 changed files with 35 additions and 0 deletions

View File

@ -15,6 +15,7 @@ namespace Bootstrap.DataAccess.MongoDB
/// </summary>
/// <returns></returns>
public override IEnumerable<BootstrapDict> RetrieveDicts() => MongoDbAccessManager.Dicts.Find(FilterDefinition<BootstrapDict>.Empty).ToList();
/// <summary>
///
/// </summary>
@ -30,5 +31,39 @@ namespace Bootstrap.DataAccess.MongoDB
MongoDbAccessManager.Dicts.BulkWrite(list);
return true;
}
/// <summary>
///
/// </summary>
/// <param name="p"></param>
/// <returns></returns>
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<BootstrapDict>.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;
}
}
/// <summary>
///
/// </summary>
/// <param name="dict"></param>
/// <returns></returns>
public override bool SaveSettings(BootstrapDict dict)
{
MongoDbAccessManager.Dicts.FindOneAndUpdate(md => md.Category == dict.Category && md.Name == dict.Name, Builders<BootstrapDict>.Update.Set(md => md.Code, dict.Code));
return true;
}
}
}