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); } }
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; }
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); } }