public static InvoiceAutoNumberYearly Save(this MongoConfig mongo, InvoiceAutoNumberYearly invAutoNumber)
 {
     mongo.MongoDatabase.GetCollection<InvoiceAutoNumberYearly>(typeof(InvoiceAutoNumberYearly).Name).
         Save<InvoiceAutoNumberYearly>(invAutoNumber);
     return invAutoNumber;
 }
        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;
        }