public static string GetClaAccessInvoiceNumber(DefaultContext db) { string newInvoiceNumberValue; lock (LockClaAccessInvoiceNumber) { string invoiceNumberValue = GetPropertiesBagItem(db, ClaAccessInvoiceNumberKey); var invoiceNumber = new InvoiceNumber(invoiceNumberValue); newInvoiceNumberValue = invoiceNumber.Next(); SavePropertiesBagItem(db, ClaAccessInvoiceNumberKey, newInvoiceNumberValue, false); } return newInvoiceNumberValue; }