public static IDGenerator GetMemberIDGenerator(ApplicationDbContext dbContext) { if (_memberIDGenerator == null) { lock (typeof(IDGenerator)) { if (_memberIDGenerator == null) { var lastMemberID = dbContext.Members .OrderByDescending(m => m.RegisterDate) .Take(1) .Select(m => m.MemberID) .FirstOrDefault(); _memberIDGenerator = IDGenerator.CreateFromID(lastMemberID, "BE"); } } } return(_memberIDGenerator); }
public static IDGenerator GetSaleToCustomerIDGenerator(ApplicationDbContext dbContext) { if (_saleToCustomerIDGenerator == null) { lock (typeof(IDGenerator)) { if (_saleToCustomerIDGenerator == null) { var lastMemberID = dbContext.SaleToCustomer .OrderByDescending(m => m.CreateDate) .Take(1) .Select(m => m.ID) .FirstOrDefault(); _saleToCustomerIDGenerator = IDGenerator.CreateFromID(lastMemberID, "STC"); } } } return(_saleToCustomerIDGenerator); }