Exemplo n.º 1
0
 /// <summary>
 /// Data validation on user input.
 /// </summary>
 /// <param name="columnName">property name</param>
 /// <returns></returns>
 public string this[string columnName]
 {
     get
     {
         if ("CardName" == columnName)
         {
             if (string.IsNullOrEmpty(CardName))
             {
                 return("Name field is empty");
             }
         }
         if ("CardNumber" == columnName)
         {
             if (string.IsNullOrEmpty(CardNumber))
             {
                 return("Card number field is empty");
             }
             if (CardNumber.Length != Constants.CARD_NUMBER_LENGTH)
             {
                 return("Invalid card number");
             }
         }
         if ("SelectedMonth" == columnName)
         {
             if (string.IsNullOrEmpty(SelectedMonth))
             {
                 return("Month field is empty");
             }
         }
         if ("SelectedYear" == columnName)
         {
             if (string.IsNullOrEmpty(SelectedYear.ToString()))
             {
                 return("Year field is empty");
             }
         }
         if ("CardCVV" == columnName)
         {
             if (string.IsNullOrEmpty(CardCVV.ToString()))
             {
                 return("CVV field is empty");
             }
             if (CardCVV.ToString().Length != Constants.CARD_CVV_LENGTH)
             {
                 return("Invalid CVV");
             }
         }
         return(string.Empty);
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// Performing the licence purchase action.
        /// </summary>
        /// <param name="parm"></param>
        private void OnPurchase(object parm)
        {
            if (!string.IsNullOrEmpty(CardName) && !string.IsNullOrEmpty(CardNumber) && !string.IsNullOrEmpty(SelectedMonth) &&
                !string.IsNullOrEmpty(SelectedYear.ToString()) && !string.IsNullOrEmpty(CardCVV.ToString()))
            {
                //Add to cart
                CartItems item = new CartItems();
                item.SubscriptionTypeId = Convert.ToInt32(AppState.Instance.SelectedSubscription.Id);
                item.Quantity           = 1;
                item.DateCreated        = DateTime.Now;
                item.UserId             = AppState.Instance.User.ServerUserId;
                HttpClient client0 = AppState.CreateClient(ServiceType.CentralizeWebApi.ToString());
                client0.DefaultRequestHeaders.Add("Authorization", "Bearer " + AppState.Instance.CentralizedToken.access_token);
                var response = client0.PostAsJsonAsync("api/Cart/Create", item).Result;
                client0.Dispose();
                // ===================

                SubscriptionList userSubscriptionList = null;
                var        serviceType = System.Configuration.ConfigurationManager.AppSettings.Get("ServiceType");
                HttpClient client      = AppState.CreateClient(ServiceType.CentralizeWebApi.ToString());
                client.DefaultRequestHeaders.Add("Authorization", "Bearer " + AppState.Instance.CentralizedToken.access_token);
                response = client.PostAsync("api/cart/OnlinePayment/" + AppState.Instance.User.ServerUserId, null).Result;
                if (response.IsSuccessStatusCode)
                {
                    var jsondata = response.Content.ReadAsStringAsync().Result;
                    if (!string.IsNullOrEmpty(jsondata))
                    {
                        userSubscriptionList = JsonConvert.DeserializeObject <SubscriptionList>(jsondata);
                        string userId = string.Empty;
                        userId = AppState.Instance.User.UserId;
                        List <UserSubscriptionData> subscriptionData = new List <UserSubscriptionData>();
                        foreach (var subDtls in userSubscriptionList.Subscriptions)
                        {
                            //Code to save the user Subscription details to Database.
                            UserSubscriptionData userSubscription = new UserSubscriptionData();
                            userSubscription.SubscriptionDate = subDtls.SubscriptionDate;
                            userSubscription.SubscriptionId   = subDtls.SubscriptionTypeId;
                            userSubscription.UserId           = userId;
                            userSubscription.Quantity         = subDtls.OrderdQuantity;
                            userSubscription.Subscription     = subDtls;
                            userSubscription.LicenseKeys      = subDtls.LicenseKeyProductMapping;
                            subscriptionData.Add(userSubscription);
                        }
                        client.Dispose();
                        HttpClient client1 = AppState.CreateClient(ServiceType.OnPremiseWebApi.ToString());
                        client1.DefaultRequestHeaders.Add("Authorization", "Bearer " + AppState.Instance.OnPremiseToken.access_token);
                        var response1 = client1.PostAsJsonAsync("api/UserSubscription/SyncSubscription", subscriptionData).Result;
                        client1.Dispose();
                    }
                }
                var kvp = new Dictionary <string, string>();
                kvp.Add("Amount", AppState.Instance.SelectedSubscription.Price.ToString());
                NavigateNextPage("RedirectToAmountPaymentPage", kvp);
            }
        }
 /// <summary>
 /// Performing the licence purchase action.
 /// </summary>
 /// <param name="parm"></param>
 private void OnPurchase(object parm)
 {
     if (!string.IsNullOrEmpty(CardName) && !string.IsNullOrEmpty(CardNumber) && !string.IsNullOrEmpty(SelectedMonth) &&
         !string.IsNullOrEmpty(SelectedYear.ToString()) && !string.IsNullOrEmpty(CardCVV.ToString()))
     {
         var kvp = new Dictionary <string, string>();
         kvp.Add("Amount", "750");
         NavigateNextPage("PurchasePage", kvp);
     }
 }