private PurchaseItem CreatePurchaseItem(System.Guid userId, Product product, ProductPrice priceOfProduct)
 {
     PurchaseItem item = new PurchaseItem()
     {
         RecipientUserId = userId,
         ProductId = product.ProductId,
         Price = priceOfProduct.Amount,
         Currency = priceOfProduct.CurrencyCode,
         Remarks = product.Name
     };
     return item;
 }
        public ActionResult SummaryOfOrder(int id, User user, Product product, ProductPrice productPrice)
        {
            try
            {
                var registDt = DateTime.Now;
                var ExpirationDate = registDt;
                //Get entitlement end date for user
                SubscriptionProductType subscriptionType = ContextHelper.GetProductType(product);
                switch (subscriptionType)
                {
                    case SubscriptionProductType.Package:
                        PackageSubscriptionProduct PackageSubscription = (PackageSubscriptionProduct)product;
                        var package = PackageSubscription.Packages.FirstOrDefault();
                        if (package != null)
                        {
                            ViewBag.ListOfDescription = ContextHelper.GetPackageFeatures(user.CountryCode, package);

                            PackageEntitlement UserPackageEntitlement = user.PackageEntitlements.FirstOrDefault(p => p.PackageId == package.PackageId);
                            if (UserPackageEntitlement != null)
                                ExpirationDate = MyUtility.getEntitlementEndDate(PackageSubscription.Duration, PackageSubscription.DurationType, ((UserPackageEntitlement.EndDate > registDt) ? UserPackageEntitlement.EndDate : registDt));
                            else
                                ExpirationDate = MyUtility.getEntitlementEndDate(PackageSubscription.Duration, PackageSubscription.DurationType, registDt);
                        }
                        break;
                    case SubscriptionProductType.Show:
                        ShowSubscriptionProduct ShowSubscription = (ShowSubscriptionProduct)product;
                        var show = ShowSubscription.Categories.FirstOrDefault();
                        if (show != null)
                        {
                            ViewBag.ShowDescription = show.Show.Blurb;
                            ShowEntitlement UserShowEntitlement = user.ShowEntitlements.FirstOrDefault(s => s.CategoryId == show.CategoryId);
                            if (UserShowEntitlement != null)
                                ExpirationDate = MyUtility.getEntitlementEndDate(ShowSubscription.Duration, ShowSubscription.DurationType, ((UserShowEntitlement.EndDate > registDt) ? UserShowEntitlement.EndDate : registDt));
                            else
                                ExpirationDate = MyUtility.getEntitlementEndDate(ShowSubscription.Duration, ShowSubscription.DurationType, registDt);
                        }
                        break;
                    case SubscriptionProductType.Episode:
                        EpisodeSubscriptionProduct EpisodeSubscription = (EpisodeSubscriptionProduct)product;
                        var episode = EpisodeSubscription.Episodes.FirstOrDefault();
                        if (episode != null)
                        {
                            EpisodeEntitlement UserEpisodeEntitlement = user.EpisodeEntitlements.FirstOrDefault(e => e.EpisodeId == episode.EpisodeId);
                            if (UserEpisodeEntitlement != null)
                                ExpirationDate = MyUtility.getEntitlementEndDate(EpisodeSubscription.Duration, EpisodeSubscription.DurationType, ((UserEpisodeEntitlement.EndDate > registDt) ? UserEpisodeEntitlement.EndDate : registDt));
                            else
                                ExpirationDate = MyUtility.getEntitlementEndDate(EpisodeSubscription.Duration, EpisodeSubscription.DurationType, registDt);
                        }
                        break;
                }
                ViewBag.ExpirationDate = ExpirationDate;
                ViewBag.ProductPrice = productPrice;
                return PartialView(product);
            }
            catch (Exception e) { MyUtility.LogException(e); }
            return null;
        }