Esempio n. 1
0
        public static void UpdateSubscriptionOnpremise(SubscriptionList subs, bool isRenewal = false)
        {
            string userId = string.Empty;

            userId = LicenseSessionState.Instance.User.UserId;
            List <UserSubscriptionData> subscriptionData = new List <UserSubscriptionData>();

            foreach (var subDtls in subs.Subscriptions)
            {
                //Code to save the user Subscription details to Database.
                UserSubscriptionData userSubscription = new UserSubscriptionData()
                {
                    SubscriptionDate = subDtls.SubscriptionDate,
                    RenewalDate      = subDtls.RenewalDate,
                    SubscriptionId   = subDtls.SubscriptionTypeId,
                    UserId           = userId,
                    Quantity         = subDtls.OrderdQuantity,
                    Subscription     = subDtls,
                    LicenseKeys      = subDtls.LicenseKeyProductMapping
                };
                subscriptionData.Add(userSubscription);
            }
            HttpClient client = WebApiServiceLogic.CreateClient(ServiceType.OnPremiseWebApi);
            string     url    = string.Empty;

            if (isRenewal)
            {
                url = "api/UserSubscription/UpdateSubscriptionRenewal/" + LicenseSessionState.Instance.User.UserId;
            }
            else
            {
                url = "api/UserSubscription/SyncSubscription";
            }
            var response = client.PostAsJsonAsync(url, subscriptionData).Result;
        }
        public void UpdateProductUpdates(List <Product> productDetails)
        {
            HttpClient client   = WebApiServiceLogic.CreateClient(ServiceType.OnPremiseWebApi);
            var        response = client.PostAsJsonAsync("api/Product/UpdateProducts", productDetails).Result;

            if (!response.IsSuccessStatusCode)
            {
                var jsonData  = response.Content.ReadAsStringAsync().Result;
                var errorData = JsonConvert.DeserializeObject <ResponseFailure>(jsonData);
                ErrorMessage = errorData.Message;
            }
            client.Dispose();
        }
Esempio n. 3
0
        public static List <SubscriptionType> GetExpireSubscription()
        {
            HttpClient client   = WebApiServiceLogic.CreateClient(ServiceType.CentralizeWebApi);
            var        response = client.GetAsync("api/UserSubscription/ExpireSubscription/" + LicenseSessionState.Instance.User.ServerUserId).Result;

            if (response.IsSuccessStatusCode)
            {
                var responseData         = response.Content.ReadAsStringAsync().Result;
                var expiredSubscriptipon = JsonConvert.DeserializeObject <List <SubscriptionType> >(responseData);
                return(expiredSubscriptipon);
            }
            return(null);
        }
Esempio n. 4
0
        /// <summary>
        /// Function to get the User License with details  for which user is authorized
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="isFeatureRequired"></param>
        /// <returns></returns>
        public static List <Product> GetTeamLicenseDetails(int teamId)
        {
            var        distinctProductList = new List <Product>();
            HttpClient client   = WebApiServiceLogic.CreateClient(ServiceType.OnPremiseWebApi);
            var        response = client.GetAsync("api/License/GetSubscriptionLicenseByTeamId/" + teamId).Result;

            if (response.IsSuccessStatusCode)
            {
                var jsonData = response.Content.ReadAsStringAsync().Result;
                distinctProductList = JsonConvert.DeserializeObject <List <Product> >(jsonData);
            }
            return(distinctProductList);
        }
Esempio n. 5
0
        public static async Task RenewSubscription(RenewSubscriptionList subscriptions)
        {
            HttpClient client   = WebApiServiceLogic.CreateClient(ServiceType.CentralizeWebApi);
            var        response = await client.PostAsJsonAsync("api/UserSubscription/RenewSubscription/" + LicenseSessionState.Instance.User.ServerUserId, subscriptions);

            if (response.IsSuccessStatusCode)
            {
                var jsonData        = response.Content.ReadAsStringAsync().Result;
                var subscripListObj = JsonConvert.DeserializeObject <SubscriptionList>(jsonData);
                if (subscripListObj != null)
                {
                    UpdateSubscriptionOnpremise(subscripListObj, true);
                }
            }
        }
Esempio n. 6
0
        public static async Task UpdateUserSubscription()
        {
            SubscriptionList userSubscriptionList = null;
            HttpClient       client = WebApiServiceLogic.CreateClient(ServiceType.CentralizeWebApi);
            var response            = await client.PostAsync("api/cart/OnlinePayment/" + LicenseSessionState.Instance.User.ServerUserId, null);

            if (response.IsSuccessStatusCode)
            {
                var jsondata = response.Content.ReadAsStringAsync().Result;
                if (!string.IsNullOrEmpty(jsondata))
                {
                    userSubscriptionList = JsonConvert.DeserializeObject <SubscriptionList>(jsondata);
                    UpdateSubscriptionOnpremise(userSubscriptionList);
                }
            }
        }
Esempio n. 7
0
        /// <summary>
        /// Function to get the Product Subscription based on the Admin Id  with count for which admin subscribed. UserId is the Admin UserId
        /// </summary>
        /// <param name="userId"></param>
        /// <returns></returns>
        public static IList <Products> GetProductsFromSubscription()
        {
            IList <Products> productsList = new List <Products>();
            HttpClient       client       = WebApiServiceLogic.CreateClient(ServiceType.OnPremiseWebApi);
            var response = client.GetAsync("api/Team/GetSubscribedProducts/").Result;

            if (response.IsSuccessStatusCode)
            {
                var jsonData = response.Content.ReadAsStringAsync().Result;
                if (!string.IsNullOrEmpty(jsonData))
                {
                    productsList = JsonConvert.DeserializeObject <IList <Products> >(jsonData);
                }
            }
            return(productsList);
        }
Esempio n. 8
0
        /// <summary>
        /// Function to get the Product Subscription based on the Admin Id  with count for which admin subscribed. UserId is the Admin UserId
        /// </summary>
        /// <param name="userId"></param>
        /// <returns></returns>
        public static IList <SubscriptionDetails> GetSubscription(string adminId)
        {
            IList <SubscriptionDetails> subscriptionProList = new List <SubscriptionDetails>();
            HttpClient client   = WebApiServiceLogic.CreateClient(ServiceType.OnPremiseWebApi);
            var        response = client.GetAsync("api/UserSubscription/SubscriptionDetils/" + adminId).Result;

            if (response.IsSuccessStatusCode)
            {
                var jsonData = response.Content.ReadAsStringAsync().Result;
                if (!string.IsNullOrEmpty(jsonData))
                {
                    subscriptionProList = JsonConvert.DeserializeObject <List <SubscriptionDetails> >(jsonData);
                }
            }
            return(subscriptionProList);
        }
        public List <Product> CheckProductUpdate(List <Product> productDetails)
        {
            List <Product> products = null;
            HttpClient     client   = WebApiServiceLogic.CreateClient(ServiceType.CentralizeWebApi);
            var            response = client.PostAsJsonAsync("api/Product/CheckProductUpdates", productDetails).Result;

            if (response.IsSuccessStatusCode)
            {
                var jsonData = response.Content.ReadAsStringAsync().Result;
                products = JsonConvert.DeserializeObject <List <Product> >(jsonData);
            }
            else
            {
                var jsonData  = response.Content.ReadAsStringAsync().Result;
                var errorData = JsonConvert.DeserializeObject <ResponseFailure>(jsonData);
                ErrorMessage = errorData.Message;
            }
            client.Dispose();
            return(products);
        }
        public List <Product> GetOnPremiseProducts()
        {
            List <Product> products = null;
            HttpClient     client   = WebApiServiceLogic.CreateClient(ServiceType.OnPremiseWebApi);
            var            response = client.GetAsync("api/Product/GetProductsByAdminId/" + LicenseSessionState.Instance.User.UserId).Result;

            if (response.IsSuccessStatusCode)
            {
                var jsonData = response.Content.ReadAsStringAsync().Result;
                products = JsonConvert.DeserializeObject <List <Product> >(jsonData);
            }
            else
            {
                var jsonData  = response.Content.ReadAsStringAsync().Result;
                var errorData = JsonConvert.DeserializeObject <ResponseFailure>(jsonData);
                ErrorMessage = errorData.Message;
            }
            client.Dispose();
            return(products);
        }
Esempio n. 11
0
        /// <summary>
        /// Function to get the User License with details  for which user is authorized
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="isFeatureRequired"></param>
        /// <returns></returns>
        public static UserLicenseDetails GetUserLicenseDetails(string userId, bool isFeatureRequired, bool fetchBasedonTeam = true)
        {
            var                   licenseMapModelList = new UserLicenseDetails();
            HttpClient            client = WebApiServiceLogic.CreateClient(ServiceType.OnPremiseWebApi);
            FetchUserSubscription subs   = new FetchUserSubscription();

            if (fetchBasedonTeam)
            {
                subs.TeamId = LicenseSessionState.Instance.AppTeamContext.Id;
            }
            subs.UserId            = userId;
            subs.IsFeatureRequired = isFeatureRequired;
            var response = client.PostAsJsonAsync("api/License/GetSubscriptionLicenseByTeam", subs).Result;

            if (response.IsSuccessStatusCode)
            {
                var jsonData = response.Content.ReadAsStringAsync().Result;
                licenseMapModelList = JsonConvert.DeserializeObject <UserLicenseDetails>(jsonData);
            }
            return(licenseMapModelList);
        }
Esempio n. 12
0
        public static List <Team> GetTeamList(string userId = "")
        {
            List <Team>         teamlst = new List <Team>();
            HttpResponseMessage response;
            HttpClient          client = WebApiServiceLogic.CreateClient(ServiceType.OnPremiseWebApi);

            if (LicenseSessionState.Instance.IsSuperAdmin && string.IsNullOrEmpty(userId))
            {
                response = client.GetAsync("api/Team/GetTeamsByAdminId/" + LicenseSessionState.Instance.User.UserId).Result;
            }
            else
            {
                response = client.GetAsync("api/Team/GetTeamsByUserId/" + userId).Result;
            }
            if (response.IsSuccessStatusCode)
            {
                var jsonData = response.Content.ReadAsStringAsync().Result;
                teamlst = JsonConvert.DeserializeObject <List <Team> >(jsonData);
            }
            return(teamlst);
        }
        public void SynchPurchaseOrder()
        {
            ErrorMessage = string.Empty;
            HttpClient client   = WebApiServiceLogic.CreateClient(ServiceType.CentralizeWebApi);
            var        response = client.GetAsync("api/purchaseorder/syncpo/" + LicenseSessionState.Instance.User.ServerUserId).Result;

            if (response.IsSuccessStatusCode)
            {
                var jsonData = response.Content.ReadAsStringAsync().Result;
                var obj      = JsonConvert.DeserializeObject <SubscriptionList>(jsonData);
                if (obj.Subscriptions.Count > 0)
                {
                    CentralizedSubscriptionLogic.UpdateSubscriptionOnpremise(obj);
                }
            }
            else
            {
                var jsonData = response.Content.ReadAsStringAsync().Result;
                var obj      = JsonConvert.DeserializeObject <ResponseFailure>(jsonData);
                ErrorMessage = response.ReasonPhrase + " - " + obj.Message;
            }
        }