public async Task<ActionResult> AddCoupon(string id)
        {
            var errorMessage = string.Empty;
            using (var repository = RepositoryFactory.GetInstance(Session))
            {
                var issuedFor = Session.GetLoggedInUser().ObjectId;
                var userPurchases = repository.FindUserPurchasesForCheckout(issuedFor).ToArray();
                Coupon coupon = await repository.FindCoupon(id);
                var existingPurchaseForCoupon = false;
                var contentItemId = string.Empty;
                var contentItemType = string.Empty;


                if (coupon.Clip != null)
                {
                    existingPurchaseForCoupon = userPurchases.Any(x => x.ClipKey != null && x.ClipKey.ObjectId == coupon.Clip.ObjectId);
                    contentItemId = coupon.Clip.ObjectId;
                    contentItemType = BL.Consts.ContentItemType.Lesson.ToString().ToLower();
                }
                else if (coupon.Bundle != null)
                {
                    existingPurchaseForCoupon = userPurchases.Any(x => x.BundleKey != null && x.BundleKey.ObjectId == coupon.Bundle.ObjectId);
                    contentItemId = coupon.Bundle.ObjectId;
                    contentItemType = BL.Consts.ContentItemType.Bundle.ToString().ToLower();
                }
                if (!existingPurchaseForCoupon)
                {

                    var shoppingCartManager = new ShoppingCartManager(Session, HttpContext);
                    var shoppoingCartItemModel = new ShoppoingCartItemModel
                    {
                        ContentItemId = contentItemId,
                        ContentItemType = contentItemType,
                    };
                    shoppingCartManager.AddToCart(shoppoingCartItemModel);
                    errorMessage = shoppoingCartItemModel.ErrorMessage;
                }
                coupon.State = "";
                await coupon.SaveAsync();
            }
            return RedirectToAction("Index", new { message = errorMessage });
        }
 public ActionResult AddToCart(ShoppoingCartItemModel cartItemModel)
 {
     var shoppingCartManager = new ShoppingCartManager(Session,HttpContext);
     shoppingCartManager.AddToCart(cartItemModel);
     return Json(cartItemModel, JsonRequestBehavior.AllowGet);
 }