private InvoiceAutoNumberDraft GetInvoiceAutoNumberDraft() { MongoCollection <InvoiceAutoNumberDraft> collection = mongo.MongoDatabase.GetCollection <InvoiceAutoNumberDraft>(typeof(InvoiceAutoNumberDraft).Name); InvoiceAutoNumberDraft invoiceAutoNumber = collection.FindOneAs <InvoiceAutoNumberDraft>(Query.And( Query.EQ("_id", BsonValue.Create(typeof(InvoiceAutoNumberDraft).Name + "-" + companyId)), Query.EQ(COMPANY_ID_FIELD, BsonValue.Create(companyId)))); if (invoiceAutoNumber == null) { invoiceAutoNumber = new InvoiceAutoNumberDraft(typeof(InvoiceAutoNumberDraft).Name, companyId); collection.Save <InvoiceAutoNumberDraft>(invoiceAutoNumber); } return(invoiceAutoNumber); }
public static InvoiceAutoNumberDraft Save(this MongoConfig mongo, InvoiceAutoNumberDraft invAutoNumber) { mongo.MongoDatabase.GetCollection<InvoiceAutoNumberDraft>(typeof(InvoiceAutoNumberDraft).Name). Save<InvoiceAutoNumberDraft>(invAutoNumber); return invAutoNumber; }
private InvoiceAutoNumberDraft GetInvoiceAutoNumberDraft() { MongoCollection<InvoiceAutoNumberDraft> collection = mongo.MongoDatabase.GetCollection<InvoiceAutoNumberDraft>(typeof(InvoiceAutoNumberDraft).Name); InvoiceAutoNumberDraft invoiceAutoNumber = collection.FindOneAs<InvoiceAutoNumberDraft>(Query.And( Query.EQ("_id", BsonValue.Create(typeof(InvoiceAutoNumberDraft).Name + "-"+ companyId)), Query.EQ(COMPANY_ID_FIELD, BsonValue.Create(companyId)))); if (invoiceAutoNumber == null) { invoiceAutoNumber = new InvoiceAutoNumberDraft(typeof(InvoiceAutoNumberDraft).Name, companyId); collection.Save<InvoiceAutoNumberDraft>(invoiceAutoNumber); } return invoiceAutoNumber; }
public static InvoiceAutoNumberDraft Save(this MongoConfig mongo, InvoiceAutoNumberDraft invAutoNumber) { mongo.MongoDatabase.GetCollection <InvoiceAutoNumberDraft>(typeof(InvoiceAutoNumberDraft).Name). Save <InvoiceAutoNumberDraft>(invAutoNumber); return(invAutoNumber); }