public SubscriptionModel UpdateSubscription(SubscriptionModel credentials)
        {
            CloudTable table = ConnectToAzureTableStorage();

            try
            {
                var password = "";
                if (credentials.password.Length < 30)
                {
                    password = new StringCipher().Encrypt(credentials.password, PassPhrase);
                }
                else
                {
                    password = credentials.password;
                }

                var status = Status.Active;
                if (credentials.status != 0)
                {
                    status = credentials.status;
                }

                SubscriptionModel entity = new SubscriptionModel(credentials.category, credentials.subscription)
                {
                    ETag               = "*",
                    customer           = credentials.customer,
                    orgurl             = credentials.orgurl,
                    discoveryurl       = credentials.discoveryurl,
                    username           = credentials.username,
                    password           = password,
                    domain             = credentials.domain,
                    partner            = credentials.partner,
                    servicestarted     = credentials.servicestarted,
                    serviceended       = credentials.serviceended,
                    subscriptionstatus = (int)status,
                    usercount          = credentials.usercount,
                    volumelicense      = credentials.volumelicense
                };

                TableOperation insertOperation = TableOperation.Merge(entity);
                table.Execute(insertOperation);

                return(entity);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
        public List <SubscriptionModel> GetAllSubscriptions()
        {
            try
            {
                CloudTable table = ConnectToAzureTableStorage();
                var        CustomerCredentialsInventoryQuery = (from entry in table.CreateQuery <SubscriptionModel>()
                                                                select entry);
                var CustomerCredentialsInventory = CustomerCredentialsInventoryQuery.ToList();
                var decryptedInventory           = new List <SubscriptionModel>();

                foreach (var item in CustomerCredentialsInventory)
                {
                    //var password = new StringCipher().Decrypt(item.password, PassPhrase);
                    //var transactionList = new TransactionHandler().GetAllTransactions(item.RowKey);

                    var customerCred = new SubscriptionModel();
                    customerCred.PartitionKey       = item.PartitionKey;
                    customerCred.RowKey             = item.RowKey;
                    customerCred.ETag               = item.ETag;
                    customerCred.customer           = item.customer;
                    customerCred.password           = item.password;
                    customerCred.discoveryurl       = item.discoveryurl;
                    customerCred.domain             = item.domain;
                    customerCred.subscription       = item.RowKey;
                    customerCred.category           = item.PartitionKey;
                    customerCred.partner            = item.partner;
                    customerCred.orgurl             = item.orgurl;
                    customerCred.username           = item.username;
                    customerCred.servicestarted     = item.servicestarted;
                    customerCred.serviceended       = item.serviceended;
                    customerCred.subscriptionstatus = item.subscriptionstatus;
                    customerCred.status             = (Status)item.subscriptionstatus;
                    customerCred.usercount          = item.usercount;
                    customerCred.volumelicense      = item.volumelicense;
                    customerCred.Timestamp          = item.Timestamp;

                    decryptedInventory.Add(customerCred);
                }

                return(decryptedInventory);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
        public bool DeleteSubscription(string customer, string subscription)
        {
            try
            {
                CloudTable table = ConnectToAzureTableStorage();

                SubscriptionModel entity = new SubscriptionModel(customer, subscription)
                {
                    ETag = "*"
                };

                TableOperation retrieveOperation = TableOperation.Delete(entity);
                TableResult    query             = table.Execute(retrieveOperation);
                return(true);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }