Example #1
0
 public void PercentOff(Voucher voucher, Basket basket, BasketVoucher basketVoucher)
 {
     if (voucher.MinSpend > basket.BasketTotal())
     {
         basketVoucher.Value = (voucher.Value * (basket.BasketTotal() / 100)) * -1;
         basketVoucher.VoucherCode = voucher.VoucherCode;
         basketVoucher.VoucherDescription = voucher.VoucherDescription;
         basketVoucher.VoucherId = voucher.VoucherId;
         basket.AddBasketVoucher(basketVoucher);
     }
 }
Example #2
0
        private Basket createNewBasket(HttpContextBase httpContext)
        {
            //create a new basket.

            //first create a new cookie.
            HttpCookie cookie = new HttpCookie(BasketSessionName);
            //now create a new basket and set the creation date.
            Basket basket = new Basket();
            basket.date = DateTime.Now;
            basket.BasketId = Guid.NewGuid();

            //add and persist in the dabase.
            baskets.Insert(basket);
            baskets.Commit();

            //add the basket id to a cookie
            cookie.Value = basket.BasketId.ToString();
            cookie.Expires = DateTime.Now.AddDays(1);
            httpContext.Response.Cookies.Add(cookie);

            return basket;
        }
Example #3
0
 public void MoneyOff(Voucher voucher, Basket basket, BasketVoucher basketVoucher)
 {
     decimal basketTotal = basket.BasketTotal();
     if (voucher.MinSpend < basketTotal )
     {
         basketVoucher.Value = voucher.Value *-1;
         basketVoucher.VoucherCode = voucher.VoucherCode;
         basketVoucher.VoucherDescription = voucher.VoucherDescription;
         basketVoucher.VoucherId = voucher.VoucherId;
         basket.AddBasketVoucher(basketVoucher);
     }
 }