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; } }
public void RemoveItem(RouteType route) { routesInCart.RemoveAll(r => r.Id == route.Id); }