コード例 #1
0
        public void AddItem(RouteType route, int quantity)
        {
            string routeToString = (route.DepartureName + "-" + route.DestinationName);

            CartLine routeLine = routesInCart
                                 .Where(r => r.Route == routeToString)
                                 .FirstOrDefault();

            if (routeLine == null)
            {
                routesInCart.Add(new CartLine
                {
                    Id         = route.Id,
                    Quantity   = quantity,
                    Route      = routeToString,
                    Price      = route.Price,
                    TotalPrice = route.Price * quantity
                });;
            }
            else
            {
                routeLine.Quantity += quantity;
            }
        }
コード例 #2
0
 public void RemoveItem(RouteType route)
 {
     routesInCart.RemoveAll(r => r.Id == route.Id);
 }