Пример #1
0
        /// <summary>
        /// Description: Get All Packages under a particular Offering
        /// </summary>
        /// <returns></returns>
        public ActionResult GetPackages()
        {
            var context = new IPTV2Entities();

            Dictionary<string, int?> packagelist = new Dictionary<string, int?>();
            IPTV2_Model.Package package = new IPTV2_Model.Package();
            string CountryCode = MyUtility.GetCurrentCountryCodeOrDefault();
            foreach (var item in context.PackageTypes.Where(ptype => ptype.OfferingId == GlobalConfig.offeringId && ptype.Country == CountryCode))
            {
                if (item is Package)
                    packagelist.Add(item.PackageName, item.PackageId);
            }

            return Json(packagelist, JsonRequestBehavior.AllowGet);
        }
Пример #2
0
 public static void UpdateRecurringBillingIfExist(IPTV2Entities context, User user, DateTime registDt, Package package, bool isPayPal = false)
 {
     if (GlobalConfig.IsRecurringBillingEnabled)
     {
         try
         {
             var recurringBillings = user.RecurringBillings.Where(r => r.StatusId == GlobalConfig.Visible && r.PackageId == package.PackageId);
             if (recurringBillings != null)
             {
                 var dtRecur = isPayPal ? registDt.Date : registDt.AddDays(-3).Date;
                 foreach (var item in recurringBillings)
                 {
                     item.EndDate = registDt;
                     item.UpdatedOn = registDt;
                     item.NumberOfAttempts = 0;
                     if (item.NextRun < dtRecur)
                         item.NextRun = dtRecur;
                 }
             }
         }
         catch (Exception e) { MyUtility.LogException(e); }
     }
 }
Пример #3
0
        public static List<string> GetPackageFeaturesViaPackage(string CountryCode, Package package)
        {
            List<string> list = null;
            string jsonString = String.Empty;
            try
            {
                var cache = DataCache.Cache;
                //modify cache duration
                var CacheDuration = new TimeSpan(0, GlobalConfig.PackageAndProductCacheDuration, 0);
                string cacheKey = "GPKGFEAT:P:" + package.PackageId + ";C:" + CountryCode;
                try { jsonString = (string)cache[cacheKey]; }
                catch (Exception) { }
                if (String.IsNullOrEmpty(jsonString))
                {
                    list = new List<string>();
                    var context = new IPTV2Entities();
                    var offering = context.Offerings.Find(GlobalConfig.offeringId);
                    var service = offering.Services.FirstOrDefault(o => o.PackageId == GlobalConfig.serviceId);
                    SortedSet<int> listOfShowIds = new SortedSet<int>();

                    foreach (var category in package.Categories)
                    {
                        listOfShowIds.UnionWith(service.GetAllOnlineShowIds(CountryCode, category.Category));
                        if (category.Category is Category)
                        {
                            var item = (Category)category.Category;
                            var CategoryShowIds = service.GetAllOnlineShowIds(CountryCode, item);
                            if (CategoryShowIds.Count() > 1000)
                                list.Add(String.Format("{0}+ in {1}", CategoryShowIds.Count().Floor(100), item.Description));
                            else if (CategoryShowIds.Count() > 100)
                                list.Add(String.Format("{0}+ in {1}", CategoryShowIds.Count().Floor(10), item.Description));
                            else if (CategoryShowIds.Count() > 10)
                                list.Add(String.Format("{0}+ in {1}", CategoryShowIds.Count().Floor(10), item.Description));
                            else
                                list.Add(String.Format("{0} in {1}", CategoryShowIds.Count(), item.Description));
                        }
                    }
                    list.Add(String.Format("{0}+ Titles", listOfShowIds.Count().Floor(10)));
                    jsonString = Newtonsoft.Json.JsonConvert.SerializeObject(list);
                    cache.Put(cacheKey, jsonString, CacheDuration);
                }
                else
                    list = Newtonsoft.Json.JsonConvert.DeserializeObject<List<string>>(jsonString);
            }
            catch (Exception e) { MyUtility.LogException(e); }
            return list;
        }