/// <summary> /// The get cart. /// </summary> /// <returns> /// The <see cref="List" />. /// </returns> public List<CartProduct> GetCart() { var products = new List<CartProduct>(); var dalProduct = new DataAccessLayer.Product(); HttpCookie cookie = this.HttpContext.Request.Cookies["cart"]; if (cookie != null) { var items = cookie.Values.AllKeys.SelectMany( cookie.Values.GetValues, (key, value) => new { id = key, amount = value }); foreach (var item in items) { BusinessObjectLayer.Product product = dalProduct.GetBy("Id", item.id); if (product != null) { products.Add(new CartProduct(int.Parse(item.amount), product)); } } } return products; }
public static DataAccessLayer.Product To_DAO(BusinessObjects.Product productBO) { DataAccessLayer.Product productDAO = new DataAccessLayer.Product(); productDAO.ID = productBO.ID; productDAO.Name = productBO.Name; productDAO.Description = productBO.Description; productDAO.Price = productBO.Price; productDAO.Stock = productBO.Stock; productDAO.CategoryID = productBO.CategoryID; productDAO.EntryDate = productBO.EntryDate; productDAO.ExpirationDate = productBO.ExpirationDate; if (productBO.Category != null) { productDAO.Category = CategoryMapper.To_DAO(productBO.Category); } return productDAO; }