示例#1
0
        public CheckCodeResult AddDiscountCode(string code)
        {
            HashSet <string> codes      = _cartDiscountCodeService.Get();
            CheckCodeResult  codeResult = _getValidDiscounts.CheckCode(_cart, code);

            if (codeResult.Success)
            {
                codes.Add(code);
                _cartDiscountCodeService.SaveDiscounts(codes);
            }
            return(codeResult);
        }
示例#2
0
        public CheckCodeResult AddDiscountCode(string code, bool fromUrl, Uri referrer = null)
        {
            HashSet <string> codes      = _cartDiscountCodeService.Get();
            CheckCodeResult  codeResult = _getValidDiscounts.CheckCode(_cart, code, fromUrl);

            if (codeResult.Success)
            {
                codes.Add(code);
                _cartDiscountCodeService.SaveDiscounts(codes);
            }
            if (referrer != null && (!referrer.IsAbsoluteUri || referrer.Authority == _site.BaseUrl))
            {
                codeResult.RedirectUrl = referrer.ToString();
            }
            return(codeResult);
        }