protected async void RedeemButtonOnClick(object sender, EventArgs e) { #region redeem product try { Status = string.Empty; Message = string.Empty; int quantity; var isParsed = int.TryParse(tbQuantity.Text.Trim(), out quantity); if (!isParsed) { Status = Convert.ToString((int)Constants.StatusCode.Error); Message = RewardsHelper.GetTranslation(TranslationKeys.Redemption.InvalidQuantity); ShowMessage(Status, Message); return; } ProductDetails = Common.DeserializeObject <ProductDetails>(ProductDetailsField.Value); if (!HasSession) { Response.Redirect(string.Format(@"/_Secure/Login.aspx?redirect=/Catalogue/Redeem.aspx&productId={0}", ProductIdField.Value), false); return; } var productType = (ProductTypeEnum)int.Parse(ProductDetails.ProductType); var response = await RedemptionStrategy.Initialize(GetRequest(productType)).Redeem(); Status = Convert.ToString(response.Code); Message = response.Message; ShowMessage(Status, Message); RefreshPoints(); } catch (Exception exception) { Status = Convert.ToString((int)Constants.StatusCode.Error); Message = RewardsHelper.GetTranslation(TranslationKeys.Errors.Exception); ShowMessage(Status, Message); AuditTrail.AppendLog(exception); } #endregion }
protected async void btnSubmit_Click(object sender, EventArgs e) { try { var formats = new[] { "MM/dd/yyyy" }; DateTime fromDate; var isParsed = DateTime.TryParseExact(dateFrom.Value, formats, CultureInfo.InvariantCulture, DateTimeStyles.None, out fromDate); if (!isParsed) { ShowMessage("wrongfromdate"); return; } DateTime toDate; isParsed = DateTime.TryParseExact(dateTo.Value, formats, CultureInfo.InvariantCulture, DateTimeStyles.None, out toDate); if (!isParsed) { ShowMessage("wrongtodate"); return; } if (fromDate > toDate) { ShowMessage("wrongdaterange"); return; } var memberCode = UserSessionInfo == null ? string.Empty : UserSessionInfo.MemberCode; toDate = toDate.AddHours(23).AddMinutes(59).AddSeconds(59); var type = HttpContext.Current.Request.QueryString.Get("type"); if (string.IsNullOrEmpty(type)) { return; } var html = string.Empty; switch (type) { case "redeemed": Title = RewardsHelper.GetTranslation(TranslationKeys.Redemption.RedemptionListing); html = await GetRedemptionList(memberCode, fromDate, toDate); break; case "expired": Title = RewardsHelper.GetTranslation(TranslationKeys.Redemption.PointsExpired); html = await GetExpiredList(memberCode, fromDate, toDate); break; case "adjusted": Title = RewardsHelper.GetTranslation(TranslationKeys.Redemption.PointsAdjusted); html = await GetAdjustmentList(memberCode, fromDate, toDate); break; } if (!string.IsNullOrEmpty(html)) { resultpanel.InnerHtml = html; } else { ShowMessage("nodata"); resultpanel.InnerHtml = string.Empty; } } catch (Exception exception) { ShowMessage("FAIL"); AuditTrail.AppendLog(exception); } }
private async void SetProductInfo() { try { var productId = HttpContext.Current.Request.QueryString.Get("id"); if (string.IsNullOrEmpty(productId)) { Response.Redirect("/Catalogue?categoryId=0&sortBy=2", false); return; } RedirectUri = !HasSession ? string.Format(@"/_Secure/Login.aspx?redirect=/Catalogue/Redeem.aspx&productId={0}", productId) : string.Format(@"/Catalogue/Redeem.aspx?productId={0}", productId); var process = await RewardsHelper.GetProductDetails(UserSessionInfo, productId); if (process == null || process.Data == null) { return; } var productDetails = (ProductDetails)process.Data; // Set label and image values if (!string.IsNullOrEmpty(productDetails.CurrencyCode)) { lblCurrency.Text = productDetails.CurrencyCode; CurrencyDiv.Visible = true; } imgPic.ImageUrl = productDetails.ImageUrl; var pointsLabelText = RewardsHelper.GetTranslation(TranslationKeys.Label.Points); if (!string.IsNullOrEmpty(productDetails.DiscountPoints) && int.Parse(productDetails.DiscountPoints) != 0) { lblPointCenter.Text = string.Format(@"{0:#,###,##0.##} {1}", productDetails.DiscountPoints, pointsLabelText); lblBeforeDiscount.Text = string.Format(@"{0:#,###,##0.##} {1}", productDetails.PointsRequired, pointsLabelText); } else { lblPointCenter.Text = string.Format(@"{0:#,###,##0.##} {1}", productDetails.PointsRequired, pointsLabelText); lblBeforeDiscount.Text = string.Empty; } if (!string.IsNullOrEmpty(productDetails.DeliveryPeriod)) { lblDelivery.Text = productDetails.DeliveryPeriod; DeliveryDiv.Visible = true; } lblDescription.Text = productDetails.ProductDescription; lblName.Text = productDetails.ProductName; IsVipOnly = productDetails.Status == (int)Constants.ProductStatus.VipOnly; IsValidRedemption = !IsVipOnly; VipOnlyMessage = RewardsHelper.GetTranslation(TranslationKeys.Redemption.VipOnly); var vipCategoryId = Common.GetAppSetting <string>("vipCategoryId"); if (!productDetails.CategoryId.Equals(vipCategoryId)) { return; } var redemptionLimitResult = await RewardsHelper.CheckRedemptionLimitForVipCategory(UserSessionInfo.MemberCode, vipCategoryId); switch (redemptionLimitResult) { case 0: VipOnlyMessage = RewardsHelper.GetTranslation(TranslationKeys.Redemption.BirthdayItemRedeemed); IsLimitReached = true; break; case 1: VipOnlyMessage = RewardsHelper.GetTranslation(TranslationKeys.Redemption.BirthdayItemPending); IsPending = true; break; } } catch (Exception exception) { AuditTrail.AppendLog(exception); } }
private async void SetProductInfo() { var memberCode = UserSessionInfo == null ? "" : UserSessionInfo.MemberCode; var countryCode = MemberSession == null ? "0" : MemberSession.CountryCode; var currencyCode = MemberSession == null ? "0" : MemberSession.CurrencyCode; try { ProductType = ProductDetails.ProductType; if (ProductType == "1" && (ProductDetails.CurrencyCode != currencyCode)) { Response.Redirect("/Catalogue?categoryId=53&sortBy=2", false); return; } if (ProductDetails.CountryCode.Trim() != "All") { if (!ProductDetails.CountryCode.Contains(countryCode)) { Response.Redirect(string.Format("/Catalogue?categoryId={0}&sortBy=2", ProductDetails.CategoryId), false); return; } } ProductIdField.Value = ProductDetails.ProductId; /** * freebet show currency, hide recipient panel , hide delivery, hide account * normal product show recipient, show delivery if any, hide currency, hide account * online show account, hide delivery, hide recipient, hide currency **/ switch (ProductType) { case "1": //freebet CurrencyDiv.Visible = true; RecipientDiv.Visible = false; DeliveryDiv.Visible = false; AccountDiv.Visible = false; break; case "2": //normal RecipientDiv.Visible = true; CurrencyDiv.Visible = false; AccountDiv.Visible = false; break; case "3": //wishlist same as normal RecipientDiv.Visible = true; CurrencyDiv.Visible = false; AccountDiv.Visible = false; break; case "4": //online AccountDiv.Visible = true; CurrencyDiv.Visible = false; RecipientDiv.Visible = false; DeliveryDiv.Visible = false; break; } //vip cannot select quantity var vipCategoryId = Common.GetAppSetting <string>("vipCategoryId"); if (ProductDetails.CategoryId == vipCategoryId) { tbQuantity.Enabled = false; } imgPic.ImageUrl = ProductDetails.ImageUrl; var pointsLabelText = RewardsHelper.GetTranslation(TranslationKeys.Label.Points); if (!string.IsNullOrEmpty(ProductDetails.DiscountPoints) && int.Parse(ProductDetails.DiscountPoints) != 0) { lblPointCenter.Text = string.Format(@"{0:#,###,##0.##} {1}", ProductDetails.DiscountPoints, pointsLabelText); lblBeforeDiscount.Text = string.Format(@"{0:#,###,##0.##} {1}", ProductDetails.PointsRequired, pointsLabelText); } else { lblPointCenter.Text = string.Format(@"{0:#,###,##0.##} {1}", ProductDetails.PointsRequired, pointsLabelText); lblBeforeDiscount.Text = string.Empty; } lblName.Text = ProductDetails.ProductName; lblCategory.Text = ProductDetails.ProductCategoryName; if (!string.IsNullOrEmpty(ProductDetails.DeliveryPeriod)) { lblDelivery.Text = ProductDetails.DeliveryPeriod; DeliveryDiv.Visible = true; } if (!string.IsNullOrEmpty(ProductDetails.CurrencyCode)) { lblCurrency.Text = ProductDetails.CurrencyCode; } if (ProductType != "2" && ProductType != "3") //normal & wishlist { return; } #region memberInfo var redemptionDetails = await RewardsHelper.GetMemberRedemptionDetails(memberCode); if (redemptionDetails == null) { return; } tbRName.Text = redemptionDetails.FullName; tbAddress.Value = redemptionDetails.Address; tbPostal.Text = redemptionDetails.Postal; tbCity.Text = redemptionDetails.City; tbCountry.Text = redemptionDetails.CountryCode; tbContact.Text = redemptionDetails.Mobile; if (ProductDetails.Status != (int)Constants.ProductStatus.VipOnly) { return; } Status = Convert.ToString((int)Constants.StatusCode.MemberVip); Message = RewardsHelper.GetTranslation(TranslationKeys.Redemption.VipOnly); ShowMessage(Status, Message); redeemButton.Visible = false; #endregion } catch (Exception exception) { AuditTrail.AppendLog(exception); } }