示例#1
0
 public static InvoiceAutoNumberYearly Save(this MongoConfig mongo, InvoiceAutoNumberYearly invAutoNumber)
 {
     mongo.MongoDatabase.GetCollection<InvoiceAutoNumberYearly>(typeof(InvoiceAutoNumberYearly).Name).
         Save<InvoiceAutoNumberYearly>(invAutoNumber);
     return invAutoNumber;
 }
示例#2
0
        private InvoiceAutoNumberYearly GetInvoiceAutoNumberYearly()
        {
            MongoCollection<InvoiceAutoNumberYearly> collection = mongo.MongoDatabase.GetCollection<InvoiceAutoNumberYearly>(typeof(InvoiceAutoNumberYearly).Name);
            InvoiceAutoNumberYearly invoiceAutoNumber = collection.FindOneAs<InvoiceAutoNumberYearly>(Query.And(
                Query.EQ("_id", BsonValue.Create(transactionDate.Year.ToString())),
                Query.EQ(COMPANY_ID_FIELD, BsonValue.Create(companyId))));

            if (invoiceAutoNumber == null)
            {
                invoiceAutoNumber = new InvoiceAutoNumberYearly(transactionDate.Year.ToString(), companyId, transactionDate.Year);
                collection.Save<InvoiceAutoNumberYearly>(invoiceAutoNumber);
            }

            return invoiceAutoNumber;
        }