public List <LicenseKeyProductMapping> GenerateLicenseKey(UserSubscription subs, int teamId)
        {
            SubscriptionDetailLogic    detailLogic = new SubscriptionDetailLogic();
            ProductLogic               produLogic  = new ProductLogic();
            SubscriptionTypeLogic      logic       = new SubscriptionTypeLogic();
            SubscriptionType           type        = logic.GetById(subs.SubscriptionTypeId);
            List <SubscriptionDetails> details     = detailLogic.GetSubscriptionDetails(subs.SubscriptionTypeId);
            int qty = subs.Quantity;
            List <LicenseKeyProductMapping> licProductMapping = new List <LicenseKeyProductMapping>();
            List <string> chuksum = new List <string>();

            foreach (var data in details)
            {
                var    pro     = produLogic.GetProductById(data.ProductId);
                var    count   = data.Quantity;
                string keyData = pro.ProductCode + "^" + subs.ExpireDate.Date.ToString() + "^" + type.Id + "^" + teamId;
                for (int i = 0; i < (data.Quantity * qty); i++)
                {
                    var    key  = LicenseKey.LicenseKeyGen.CryptoEngine.Encrypt(keyData, true);
                    string key1 = string.Empty;
                    do
                    {
                        var keygeneration = new LicenseKey.GenerateKey();
                        keygeneration.LicenseTemplate = "xxxxxxxxxxxxxxxxxxxx-xxxxxxxxxxxxxxxxxxxx";
                        keygeneration.UseBase10       = false;
                        keygeneration.UseBytes        = false;
                        keygeneration.CreateKey();
                        key1 = keygeneration.GetLicenseKey();
                    } while (chuksum.Contains(key1));
                    var licKey = key + "-" + key1;
                    licProductMapping.Add(new LicenseKeyProductMapping()
                    {
                        LicenseKey = licKey, ProductId = pro.Id
                    });
                }
            }
            return(licProductMapping);
        }
        public Subscription GetSubscriptionWithLicense(UserSubscription sub, int teamId)
        {
            Subscription            purchasedSubscription = new Subscription();
            SubscriptionTypeLogic   typeLogic             = new SubscriptionTypeLogic();
            SubscriptionDetailLogic detailsLogic          = new SubscriptionDetailLogic();

            purchasedSubscription.LicenseKeyProductMapping = GenerateLicenseKey(sub, teamId);
            purchasedSubscription.SubscriptionTypeId       = sub.SubscriptionTypeId;
            purchasedSubscription.SubscriptionDate         = sub.ActivationDate;
            purchasedSubscription.RenewalDate      = sub.RenewalDate;
            purchasedSubscription.OrderdQuantity   = sub.Quantity;
            purchasedSubscription.SubscriptionType = typeLogic.GetById(sub.SubscriptionTypeId);
            var details = detailsLogic.GetSubscriptionDetails(purchasedSubscription.SubscriptionTypeId);
            var proList = new List <Product>();

            foreach (var dt in details)
            {
                var pro = dt.Product;
                pro.Quantity = dt.Quantity;
                proList.Add(pro);
            }
            purchasedSubscription.SubscriptionType.Products = proList;
            return(purchasedSubscription);
        }