public CartUpdateStatus Update(System.Web.HttpRequest req, string giftVoucherCode) { for (int i = 0; i < ShoppingItems.BasketItems.Rows.Count; i++) { DataRow row = ShoppingItems.BasketItems.Rows[i]; string id = row["ItemId"].ToString(); string options = row["OptionsKey"].ToString(); int qty = 0; if (req.Form[string.Format("Remove_{0}_{1}", id, StringUtils.SQLEncode(options))] != "on") { try { qty = Int32.Parse(req.Form[string.Format("Qty_{0}_{1}", id, StringUtils.SQLEncode(options))]); } catch { qty = (int)row["Quantity"]; } } this.UpdateItem((int)row["ItemId"], qty, options, "", false); if (qty == 0) { i--; } } if (!String.IsNullOrEmpty(giftVoucherCode)) { if (giftVoucherCode != MaskVoucher()) { GiftVouchers gf = new GiftVouchers(); OrdersDS.GiftVouchersRow voucher = gf.GetGiftVoucherByCode(giftVoucherCode); if (voucher == null) { return(CartUpdateStatus.IncorrectGiftVoucher); } if (voucher.Status == (byte)1) { return(CartUpdateStatus.IncorrectGiftVoucher); } ShoppingItems.GiftVouvher = giftVoucherCode; ShoppingItems.GiftVoucherValue = voucher.Amount; AdjustTotals(true); return(CartUpdateStatus.GiftVoucherSuccessfullyAdded); } } else if (MaskVoucher() != "") { ShoppingItems.GiftVouvher = ""; ShoppingItems.GiftVoucherValue = 0; } AdjustTotals(true); return(CartUpdateStatus.Success); }
public bool CheckVoucherCode() { bool passed = true; if (this.ShoppingItems.GiftVouvher != "") { GiftVouchers gf = new GiftVouchers(); OrdersDS.GiftVouchersRow voucher = gf.GetGiftVoucherByCode(this.ShoppingItems.GiftVouvher); if (voucher == null || voucher.Status == 1) { passed = false; } } return(passed); }