/// <summary>
        ///
        /// </summary>
        /// <param name="shoppingCartModel"></param>
        /// <returns></returns>
        public ShoppingCartModel CreateShoppingCart(ShoppingCartModel shoppingCartModel)
        {
            var newShoppingCart = new ShoppingCart()
            {
                Id               = shoppingCartModel.id,
                Date             = DateTime.Now,
                ShoppingProducts = new List <ShoppingProduct>()
            };

            _shoppingCartRepository.Add(newShoppingCart);

            _context.SaveChanges();

            if (shoppingCartModel.shoppingProducts != null && shoppingCartModel.shoppingProducts.Count > 0)
            {
                foreach (var prod in shoppingCartModel.shoppingProducts)
                {
                    newShoppingCart.ShoppingProducts.Add(CreateShoppingProduct(prod));
                }
            }

            _context.SaveChanges();

            return(ShoppingCartModelBuilder.Create(newShoppingCart));
        }
 public ShoppingCartController(IWorkContext workContext,
                               IArticleService articleService,
                               IShoppingCartService shoppingCartService,
                               ShoppingCartModelBuilder buidler)
 {
     _workContext         = workContext;
     _articleService      = articleService;
     _shoppingCartService = shoppingCartService;
     _buidler             = buidler;
 }
 public ShoppingCartModel GetShoppingCart(int id)
 {
     return(ShoppingCartModelBuilder.Create(_shoppingCartRepository.GetById(id)));
 }