public void SaveContracts(string characterId, ContractSave save) { lock (sync) { s_Log.InfoFormat("save contracts for character = {0}".Color(LogColor.red), characterId); var document = m_ContractDocuments.FindOne(Query <ContractDocument> .EQ(c => c.characterId, characterId)); if (document == null) { document = new ContractDocument { characterId = characterId }; } document.isNewDocument = false; document.Set(save); m_ContractDocuments.Save(document); } }
public ContractSave LoadContracts(string characterId, IRes resource, out bool isNew) { lock (sync) { s_Log.InfoFormat("load contracts for character = {0}", characterId); var document = m_ContractDocuments.FindOne(Query <ContractDocument> .EQ(c => c.characterId, characterId)); if (document != null) { isNew = false; return(document.SourceObject(resource)); } else { isNew = true; document = new ContractDocument { characterId = characterId, isNewDocument = isNew, activeContracts = new System.Collections.Generic.List <System.Collections.Hashtable>(), completedContracts = new System.Collections.Generic.List <System.Collections.Hashtable>() }; m_ContractDocuments.Save(document); return(document.SourceObject(resource)); } } }