예제 #1
0
        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);
        }
예제 #2
0
 public static InvoiceAutoNumberDraft Save(this MongoConfig mongo, InvoiceAutoNumberDraft invAutoNumber)
 {
     mongo.MongoDatabase.GetCollection<InvoiceAutoNumberDraft>(typeof(InvoiceAutoNumberDraft).Name).
         Save<InvoiceAutoNumberDraft>(invAutoNumber);
     return invAutoNumber;
 }
예제 #3
0
        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;
        }
예제 #4
0
 public static InvoiceAutoNumberDraft Save(this MongoConfig mongo, InvoiceAutoNumberDraft invAutoNumber)
 {
     mongo.MongoDatabase.GetCollection <InvoiceAutoNumberDraft>(typeof(InvoiceAutoNumberDraft).Name).
     Save <InvoiceAutoNumberDraft>(invAutoNumber);
     return(invAutoNumber);
 }