Exemplo n.º 1
0
 public void CalculateOrder(User user, CartModel cart)
 {
     decimal discount = (decimal) (user.Point > 200
                                    ? 0.15
                                    : user.Point >= 100
                                          ? 0.1
                                          : user.Point > 50
                                                ? 0.05
                                                : 0);
     cart.Total = cart.SubTotal*(1 - discount);
 }
Exemplo n.º 2
0
 public CartModel GetCart()
 {
     CartModel cart = new CartModel
                             {
                                 CartItems = GetCartFromSession().Select(kp => kp.Value)
                             };
     cart.SubTotal = cart.CartItems.Sum(item => item.ItemTotal);
     var user = new AccountService().UserRepository.FindByUserName(HttpContext.Current.User.Identity.Name);
     CalculateOrder(user, cart);
     return cart;
 }
Exemplo n.º 3
0
 public void CalculateOrderTest(string message, User user, CartModel cart, decimal expectedResult)
 {
     _cartService.CalculateOrder(user, cart);
     Assert.AreEqual(expectedResult, cart.Total, message);
 }