Added RedirectUsingNamedRoute
[castle.git] / Samples / Castle / PetStore.Web / Controllers / State / CartState.cs
blobefcbf76aad136d4572cf0b2bf0a8a6faae2e8f6f
1 // Copyright 2004-2008 Castle Project - http://www.castleproject.org/
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
15 namespace PetStore.Web.Controllers.State
17 using System;
18 using System.Collections;
20 /// <summary>
21 /// Session state pattern to hold the
22 /// cart data.
23 /// </summary>
24 [Serializable]
25 public class CartState : IEnumerable
27 private IList items = new ArrayList();
29 public void Add(int quantity, int productId)
31 items.Add(new CartItem(quantity, productId));
34 public void Remove(CartItem item)
36 items.Remove(item);
39 public IList Items
41 get { return items; }
44 public class CartItem
46 private readonly int quantity;
47 private readonly int productId;
49 public CartItem(int quantity, int productId)
51 this.quantity = quantity;
52 this.productId = productId;
55 public int Quantity
57 get { return quantity; }
60 public int ProductId
62 get { return productId; }
66 #region IEnumerable Members
68 public IEnumerator GetEnumerator()
70 return items.GetEnumerator();
73 #endregion