增加功能:增加保存字典方法
This commit is contained in:
parent
99a8b5432d
commit
e681580d2d
|
@ -15,6 +15,7 @@ namespace Bootstrap.DataAccess.MongoDB
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public override IEnumerable<BootstrapDict> RetrieveDicts() => MongoDbAccessManager.Dicts.Find(FilterDefinition<BootstrapDict>.Empty).ToList();
|
public override IEnumerable<BootstrapDict> RetrieveDicts() => MongoDbAccessManager.Dicts.Find(FilterDefinition<BootstrapDict>.Empty).ToList();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -30,5 +31,39 @@ namespace Bootstrap.DataAccess.MongoDB
|
||||||
MongoDbAccessManager.Dicts.BulkWrite(list);
|
MongoDbAccessManager.Dicts.BulkWrite(list);
|
||||||
return true;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue