Esempio n. 1
0
        static string DefaultCurrency = "USD";  // Use for cross conversion

        public static decimal Convert(IPTV2Entities context, string baseCurrency, string targetCurrency, decimal amount)
        {
            decimal  newAmount = amount;

            if (baseCurrency == targetCurrency)
                return amount;

            var thisRate = context.Forexes.Find(new string[] { baseCurrency, targetCurrency });
            if (thisRate != null)
            {
                return (decimal)((double)amount * thisRate.ExchangeRate);
            }
            else
            {
                thisRate = context.Forexes.Find(new string[] { targetCurrency, baseCurrency });
                if (thisRate != null)
                {
                    return (decimal)((double)amount / thisRate.ExchangeRate);
                }
                else
                {
                    // convert baseCurrency to DefaultCurrency first
                    thisRate = context.Forexes.Find(new string[] { DefaultCurrency, baseCurrency });
                    if (thisRate == null) throw new Exception("Cannot convert from base currency.");
                    newAmount = (decimal)((double)amount / thisRate.ExchangeRate);

                    // convert DefaultCurrency to targetCurrency
                    thisRate = context.Forexes.Find(new string[] { DefaultCurrency, targetCurrency });
                    if (thisRate == null) throw new Exception("Cannot convert to target currency.");
                    newAmount = (decimal)((double)newAmount * thisRate.ExchangeRate);
                }
            }

            return (newAmount);
        }
Esempio n. 2
0
        public static void TestProducts()
        {
            var context = new IPTV2Entities();
            var lite1M = context.Products.Find(5);
            var lite3M = context.Products.Find(6);
            var lite12M = context.Products.Find(7);

            var is1MUsAllowed = lite1M.IsAllowed("US"); // false
            var is3MUsAllowed = lite3M.IsAllowed("US"); // false
            var is12MUsAllowed = lite12M.IsAllowed("US"); //false

            var is1MJpAllowed = lite1M.IsAllowed("JP"); // true
            var is3MJpAllowed = lite3M.IsAllowed("JP"); // true
            var is12MJpAllowed = lite12M.IsAllowed("JP"); //true


            var prem1M = context.Products.Find(1);
            var prem3M = context.Products.Find(3);
            var prem12M = context.Products.Find(4);
            var prem10D = context.Products.Find(2);

            var isPrem1M = prem1M.IsAllowed("US"); // true
            var isPrem3M = prem3M.IsAllowed("US"); // true
            var isPrem12M = prem12M.IsAllowed("US");  // true
            var isPrem10D = prem10D.IsAllowed("US");  // true

            var ae = context.Countries.Find("AE");
            var aePricePrem1M = prem1M.GetPrice(ae);

            var us = context.Countries.Find("US");
            var usPriceLite1M = lite1M.GetPrice(us);

        }
Esempio n. 3
0
        public ActionResult Verify(string id)
        {
            if (String.IsNullOrEmpty(id))
                return new HttpNotFoundResult();
            System.Guid g;
            if (!System.Guid.TryParse(id, out g))
                return new HttpNotFoundResult();

            var context = new IPTV2Entities();
            var tester = context.BetaTesters.FirstOrDefault(b => b.InvitationKey == new System.Guid(id) && b.DateClaimed == null);
            if (tester != null)
            {
                //tester.DateClaimed = DateTime.Now;
                //tester.IpAddress = Request.GetUserHostAddressFromCloudflare();
                //if (context.SaveChanges() > 0)
                //{
                //    HttpCookie cookie = new HttpCookie("testerid");
                //    cookie.Value = id;
                //    cookie.Expires = DateTime.Now.AddYears(10);
                //    this.ControllerContext.HttpContext.Response.SetCookie(cookie);
                //    //return RedirectToAction("Index", "Home");
                //    return RedirectToAction("Register", "User");
                //}

                HttpCookie cookie = new HttpCookie("testerid");
                cookie.Value = id;
                cookie.Expires = DateTime.Now.AddYears(10);
                this.ControllerContext.HttpContext.Response.SetCookie(cookie);
                return RedirectToAction("Register", "User", new { iid = id });
            }
            else
                return Content("Key already used.", "text/html");

            //return new HttpNotFoundResult();
        }
Esempio n. 4
0
        public PartialViewResult GetPlayList(int? id)
        {
            var context = new IPTV2Entities();
            if (id == null)
            {
                id = GlobalConfig.FreeTVPlayListId;
            }
            var feature = context.Features.FirstOrDefault(f => f.FeatureId == id && f.StatusId == GlobalConfig.Visible);
            if (feature == null)
                return null;

            List<FeatureItem> featureItems = context.FeatureItems.Where(f => f.FeatureId == id && f.StatusId == GlobalConfig.Visible).ToList();
            List<JsonFeatureItem> jfi = new List<JsonFeatureItem>();
            foreach (EpisodeFeatureItem f in featureItems)
            {
                if (f is EpisodeFeatureItem)
                {
                    Episode ep = context.Episodes.Find(f.EpisodeId);
                    if (ep != null)
                    {
                        Show show = ep.EpisodeCategories.FirstOrDefault(e => e.CategoryId != GlobalConfig.FreeTvCategoryId).Show;
                        if (show != null)
                        {
                            string img = String.IsNullOrEmpty(ep.ImageAssets.ImageVideo) ? GlobalConfig.AssetsBaseUrl + GlobalConfig.BlankGif : String.Format("{0}{1}/{2}", GlobalConfig.EpisodeImgPath, ep.EpisodeId.ToString(), ep.ImageAssets.ImageVideo);
                            string showImg = String.IsNullOrEmpty(show.ImagePoster) ? GlobalConfig.AssetsBaseUrl + GlobalConfig.BlankGif : String.Format("{0}{1}/{2}", GlobalConfig.ShowImgPath, show.CategoryId.ToString(), show.ImagePoster);
                            JsonFeatureItem j = new JsonFeatureItem() { EpisodeId = ep.EpisodeId, EpisodeDescription = ep.Description, EpisodeName = ep.EpisodeName, EpisodeAirDate = (ep.DateAired != null) ? ep.DateAired.Value.ToString("MMMM d, yyyy") : "", ShowId = show.CategoryId, ShowName = show.CategoryName, EpisodeImageUrl = img, ShowImageUrl = showImg, Blurb = MyUtility.Ellipsis(ep.Synopsis, 80) };
                            jfi.Add(j);
                        }
                    }
                }
            }
            ViewBag.FeaturedId = id;
            return PartialView("_GetPlayList", jfi);
        }
        public ActionResult List(int id = 1)
        {
            int page = id;

            var context = new IPTV2Entities();
            var episodeIds = context.EpisodeCategories1.Where(e => e.CategoryId == GlobalConfig.KwentoNgPaskoCategoryId && e.Episode.OnlineStatusId == GlobalConfig.Visible).OrderByDescending(e => e.Episode.AuditTrail.CreatedOn)
                .Skip((page - 1) * pageSize)
                .Take(pageSize)
                .Select(e => e.EpisodeId);

            var totalCount = context.EpisodeCategories1.Count(e => e.CategoryId == GlobalConfig.KwentoNgPaskoCategoryId && e.Episode.OnlineStatusId == GlobalConfig.Visible);
            ViewBag.CurrentPage = page;
            ViewBag.PageSize = pageSize;

            var totalPage = Math.Ceiling((double)totalCount / pageSize);
            ViewBag.TotalPages = totalPage;
            ViewBag.TotalCount = totalCount;
            var maxCount = page * pageSize > totalCount ? totalCount : page * pageSize;
            ViewBag.OutOf = String.Format("{0} - {1}", (page * pageSize) + 1 - pageSize, maxCount);
            var episodes = context.Episodes.Where(e => episodeIds.Contains(e.EpisodeId) && e.OnlineStatusId == GlobalConfig.Visible);

            ViewBag.Previous = page == 1 ? String.Empty : (page - 1) == 1 ? String.Empty : (page - 1).ToString();
            ViewBag.Next = page == (int)totalPage ? (int)totalPage : page + 1;

            if ((page * pageSize) + 1 - pageSize > totalCount)
                return RedirectToAction("List", "KuwentongPasko", new { id = String.Empty });
            if (episodes != null)
                return View(episodes);
            return RedirectToAction("Index", "Home");
        }
Esempio n. 6
0
 public static void EntitlePackage()
 {
     var context = new IPTV2Entities();
     var user = context.Users.First(u => u.EMail == "*****@*****.**");
     var product = context.Products.Find(5);
     // user.Entitle((PackageSubscriptionProduct)product);
 }
Esempio n. 7
0
        public ActionResult Migration(string start, string end)
        {
            DateTime StartDate = Convert.ToDateTime(start);
            DateTime EndDate = Convert.ToDateTime(end);

            var context = new IPTV2Entities();
            foreach (DateTime day in MyUtility.EachDay(StartDate, EndDate))
            {
                DateTime startDt = Convert.ToDateTime(String.Format("{0} {1}", day.ToString("yyyy/MM/dd"), "00:00:00"));
                DateTime endDt = Convert.ToDateTime(String.Format("{0} {1}", day.ToString("yyyy/MM/dd"), "23:59:59"));
                var report = context.Users
                .Join(context.Countries, userdetails => userdetails.CountryCode, country => country.Code, (userdetails, country) => new { userdetails, country })
                .Join(context.GomsSubsidiaries, user => user.country.GomsSubsidiaryId, subsidiary => subsidiary.GomsSubsidiaryId, (user, subsidiary) => new { user, subsidiary })
                .Where(result => result.user.userdetails.RegistrationDate >= @startDt && result.user.userdetails.RegistrationDate <= @endDt && result.user.userdetails.TfcNowUserName != null)
                .GroupBy(result => result.subsidiary.Description)
                .Select(result => new { description = result.Key, count = result.Count() })
                .OrderByDescending(result => result.count).ToList();

                string filePath = @"C:\bin\global dropbox\Audie\Migration\";
                string fileName = startDt.ToString("yyyyMMdd") + ".csv";
                using (StreamWriter writer = new StreamWriter(filePath + fileName))
                {
                    var csv = new CsvWriter(writer);
                    csv.WriteRecords(report);
                }
            }

            return null;
        }
        public void FillCache(IPTV2Entities context, int offeringId, RightsType rightsType, TimeSpan cacheDuration)
        {
            var packageList = context.PackageTypes.Where(p => p.OfferingId == offeringId).ToList();
            var countries = context.Countries.ToList();
            // fill cache of all packages
            long totalSize = 0;
            foreach (var p in packageList)
            {
                foreach (var c in countries)
                {
                    // loop and fill cache for 1 hour
                    // fill show IDs
                    var shows = p.GetAllShowIds(c.Code, rightsType, false);
                    var cacheKey = p.GetCacheKey(c.Code, rightsType);
                    DataCache.Cache.Put(cacheKey, shows, cacheDuration);
                    totalSize += GetObjectSize(shows);

                    // fill channel IDs
                    cacheKey = p.GetChannelsCacheKey(c.Code, rightsType);
                    var channels = p.GetAllChannelIds(c.Code, rightsType, false);
                    DataCache.Cache.Put(cacheKey, channels, cacheDuration);
                }
            }


        }
Esempio n. 9
0
        public static bool CheckUser_Entitlement(Show model)
        {
            if (!HttpContext.Current.User.Identity.IsAuthenticated)
            {
                return false;
            }
            else
            {
                using (IPTV2Entities context = new IPTV2Entities())
                {
                    Guid userID = new Guid(HttpContext.Current.User.Identity.Name);
                    var user = context.Users.FirstOrDefault(u => u.UserId == userID);
                    var off = context.Offerings.Find(GlobalConfig.offeringId);
                    if (user.IsShowEntitled(off, model, RightsType.Online))
                    {
                        if (user.Entitlements.Where(t => t.OfferingId == GlobalConfig.offeringId && t.EndDate >= DateTime.Now).Count() > 0)
                        {
                            return true;
                        }
                    }

                }
            }
            return false;
        }
Esempio n. 10
0
        public override void Run()
        {

            // This is a sample worker implementation. Replace with your logic.
            Trace.WriteLine("$projectname$ entry point called", "Information");

            int waitDuration = Convert.ToInt32(RoleEnvironment.GetConfigurationSettingValue("LoopWaitDurationInSeconds"));
            int fillCacheDurationInMinutes = Convert.ToInt32(RoleEnvironment.GetConfigurationSettingValue("FillCacheDurationInMinutes"));
            bool fillCache = Convert.ToBoolean(RoleEnvironment.GetConfigurationSettingValue("FillCache"));
            while (true)
            {
                try
                {
                    Thread.Sleep(TimeSpan.FromSeconds(waitDuration));
                    int offeringId = 2;
                    var service = new GomsTfcTv();
                    var context = new IPTV2Entities();
                    var offering = context.Offerings.Find(offeringId);
                    Trace.WriteLine("Process start.");
                    // Update Forex
                    // service.GetExchangeRates(context, "USD");
                    // Process Transactions
                    // service.ProcessAllPendingTransactionsInGoms(context, offering);
                    Trace.WriteLine("Process finish.");
                }
                catch (Exception ex)
                {
                    Trace.TraceError("fail in Run", ex);
                }
            }
        }
Esempio n. 11
0
        public ActionResult Index()
        {
            var ReturnCode = new TransactionReturnType()
            {
                StatusCode = (int)ErrorCodes.NotAuthenticated,
                StatusMessage = String.Empty,
                info = "IT&E Validation",
                TransactionType = "Validation"
            };

            if (User.Identity.IsAuthenticated)
            {
                DateTime registDt = DateTime.Now;
                IPTV2Entities context = new IPTV2Entities();
                var promo = context.Promos.FirstOrDefault(p => p.PromoId == GlobalConfig.ITEPromoId && p.StartDate < registDt && registDt < p.EndDate && p.StatusId == GlobalConfig.Visible);
                if (promo != null)
                    return View();
                else { ReturnCode.StatusCode = (int)ErrorCodes.UnauthorizedCountry; }
            }
            ReturnCode.StatusMessage = MyUtility.getErrorMessage((ErrorCodes)ReturnCode.StatusCode);
            if (!String.IsNullOrEmpty(ReturnCode.StatusMessage))
            {
                TempData["ErrorMessage"] = ReturnCode;
            }
            return RedirectToAction("Index", "Home");
        }
Esempio n. 12
0
        private static void ExtendTFCnowLicenses()
        {
            DateTime registDt = DateTime.Now;
            var absnow_context = new ABSNowEntities();
            var context = new IPTV2Entities();

            var migrated_users = context.Users.Where(i => !String.IsNullOrEmpty(i.TfcNowUserName)).OrderBy(i => i.EMail);

            Console.WriteLine(String.Format("Total migrated users: {0}", migrated_users.Count()));
            int ctr = 1;
            foreach (var user in migrated_users)
            {
                //Get Entitlements
                Console.WriteLine(String.Format("{1} TFC.tv Email Address: {0}", user.EMail, ctr));
                Console.WriteLine(String.Format("TFCnow Email Address: {0}", user.TfcNowUserName));
                ctr++;
                var entitlements = user.PackageEntitlements.Where(i => i.EndDate > registDt);
                if (entitlements != null)
                {
                    foreach (var item in entitlements)
                    {
                        Console.WriteLine(String.Format("Package Id: {0}", item.PackageId));
                        Console.WriteLine(String.Format("Expiration Date: {0}", item.EndDate));
                        int TFCnowPackageId = GetTFCnowPackageId(item.PackageId);
                        absnow_context.TFCnowExtendLicense(user.TfcNowUserName, TFCnowPackageId, item.EndDate);
                    }
                }
                //absnow_context.SaveChanges();
            }
        }
Esempio n. 13
0
 public override IEnumerable<DynamicNode> GetDynamicNodeCollection()
 {
     List<DynamicNode> returnValue = null;
     var cache = DataCache.Cache;
     string cacheKey = "SMAPCELEB:O:00";
     returnValue = (List<DynamicNode>)cache[cacheKey];
     // Build value 
     if (returnValue == null)
     {
         try
         {
             returnValue = new List<DynamicNode>();
             var context = new IPTV2_Model.IPTV2Entities();
             // Create a node for each celebrity 
             var celebs = context.Celebrities.ToList();
             foreach (var celeb in celebs)
             {
                 DynamicNode node = new DynamicNode();
                 node.Key = "Celebrity-" + celeb.CelebrityId;
                 node.Title = "Celebrity - " + celeb.FullName;
                 //node.Controller = "Celebrity";
                 //node.Action = "Profile";
                 node.RouteValues.Add("id", celeb.CelebrityId);
                 returnValue.Add(node);
             }
             var cacheDuration = new TimeSpan(2, 0, 0);
             cache.Put(cacheKey, returnValue, cacheDuration);
         }
         catch (Exception) { returnValue = new List<DynamicNode>(); }
     }
     // Return 
     return returnValue;
 }
Esempio n. 14
0
 public static void ProcessAllGomsPendingTransactions()
 {
     var context = new IPTV2Entities();
     var service = new GomsTfcTv();
     var offering = context.Offerings.Find(2);
     service.ProcessAllPendingTransactionsInGoms(context, offering);
 }
        public void FillCache(IPTV2Entities context, int offeringId, int serviceId, IEnumerable<int> categoryIds, RightsType rightsType, TimeSpan cacheDuration)
        {
            var countries = context.Countries;
            var offering = context.Offerings.FirstOrDefault(o => o.OfferingId == offeringId);
            var service = offering.Services.FirstOrDefault(s => s.PackageId == serviceId);
            // fill cache of all categories
            foreach (int categoryId in categoryIds)
            {
                try
                {
                    var cat = context.CategoryClasses.FirstOrDefault(c => c.CategoryId == categoryId && c is Category);
                    if (cat != null)
                    {
                        var category = (Category)cat;
                        foreach (var c in countries)
                        {
                            try
                            {
                                // loop and fill cache for 1 hour
                                var shows = service.GetAllShowIds(c.Code, category, rightsType, false);
                                var cacheKey = service.GetCacheKey(c.Code, category, rightsType);
                                DataCache.Cache.Put(cacheKey, shows, cacheDuration);
                            }
                            catch (Exception) { }
                        }
                    }
                }
                catch (Exception) { }
            }

        }
Esempio n. 16
0
        static public void CreditCardReload()
        {
            var context = new IPTV2_Model.IPTV2Entities();
            var gomsService = new GomsTfcTv();

            var user = context.Users.FirstOrDefault(u => u.EMail == "*****@*****.**");
            if (user != null)
            {
                // create transaction
                var transaction = new IPTV2_Model.CreditCardReloadTransaction
                    {
                        Amount = 10,
                        Currency = user.Country.CurrencyCode,
                        Date = DateTime.Now,
                    };

                var resp = gomsService.ReloadWalletViaCreditCard(context, user.UserId, transaction, GetCreditCard());
                if (resp.IsSuccess)
                {
                    // YEY
                }

            }

        }
Esempio n. 17
0
        public ActionResult ContenderDetails(int? id)
        {
            if (id != null)
            {
                var context = new IPTV2Entities();
                var celebrity = context.Celebrities.FirstOrDefault(c => c.CelebrityId == id);
                var socialContext = new EngagementsEntities();
                if (celebrity != null)
                {
                    if (String.IsNullOrEmpty(celebrity.Description))
                        celebrity.Description = "No description yet.";

                    if (String.IsNullOrEmpty(celebrity.ImageUrl))
                        celebrity.ImageUrl = String.Format("{0}/{1}", GlobalConfig.AssetsBaseUrl, "content/images/celebrity/unknown.jpg");
                    else
                        celebrity.ImageUrl = String.Format("{0}{1}/{2}", GlobalConfig.CelebrityImgPath, celebrity.CelebrityId, celebrity.ImageUrl);

                    if (MyUtility.isUserLoggedIn() && ContextHelper.HasSocialEngagement(new System.Guid(User.Identity.Name), GlobalConfig.SOCIAL_LOVE, (int)id, EngagementContentType.Celebrity))
                        ViewBag.Loved = true;
                    var lovesCountSummary = socialContext.CelebrityReactionSummaries.FirstOrDefault(i => i.CelebrityId == celebrity.CelebrityId && i.ReactionTypeId == GlobalConfig.SOCIAL_LOVE);
                    int love = (int)(lovesCountSummary == null ? 0 : lovesCountSummary.Total);
                    celebrity.Weight = love.ToString();
                    if (!String.IsNullOrEmpty(celebrity.Birthday))
                        ViewBag.BirthDate = celebrity.Birthday;
                    if (!String.IsNullOrEmpty(celebrity.Birthplace))
                    {
                        ViewBag.BirthPlace = celebrity.Birthplace;
                        celebrity.Birthplace = "<p>" + celebrity.FirstName + " VS " + celebrity.Birthplace.Replace(",", "</p><p>" + celebrity.FirstName + " VS ") + "</p>";
                        celebrity.Birthplace = celebrity.Birthplace.Replace(":", "<br />");
                    }
                    return View(celebrity);
                }
            }
            return RedirectToAction("Index", "Home");
        }
Esempio n. 18
0
        private static void mytest()
        {
            using (var context = new IPTV2Entities())
            {
                var offering = context.Offerings.Find(2);

                var show = (Show)context.CategoryClasses.Find(333);
                var packageProductIds = show.GetPackageProductIds(offering, "US", RightsType.Online);
                var showProductIds = show.GetShowProductIds(offering, "US", RightsType.Online);

                var subscriptionProducts = SubscriptionProductC.LoadAll(context, offering.OfferingId, true)
                                           .Where(p => p.IsAllowed("US"));

                var packageProducts = from products in subscriptionProducts
                                      join id in packageProductIds
                                      on products.ProductId equals id
                                      select products;

                var showProducts = from products in subscriptionProducts
                                   join id in showProductIds
                                   on products.ProductId equals id
                                   select products;



            }
        }
 public JsonResult GetStore(string id)
 {
     var context = new IPTV2Entities();
     var result = context.StoreFronts.Where(s => (s.BusinessName.Contains(id) || s.Address1.Contains(id) || s.City.Contains(id)) && s.StatusId == GlobalConfig.Visible && s.OfferingId == GlobalConfig.offeringId);
     List<StoreFront> list = new List<StoreFront>();
     foreach (var item in result)
     {
         list.Add(new StoreFront()
         {
             StoreFrontId = item.StoreFrontId,
             BusinessName = item.BusinessName,
             ContactPerson = item.ContactPerson,
             Address1 = item.Address1,
             Address2 = item.Address2,
             City = item.City,
             State = item.State,
             ZipCode = item.ZipCode,
             CountryCode = item.CountryCode,
             BusinessPhone = item.BusinessPhone,
             EMailAddress = item.EMailAddress,
             WebSiteUrl = item.WebSiteUrl,
             MobilePhone = item.MobilePhone,
             Latitude = item.Latitude,
             Longitude = item.Longitude
         });
     }
     return this.Json(list, JsonRequestBehavior.AllowGet);
 }
Esempio n. 20
0
        public ActionResult Index()
        {
            var context = new IPTV2Entities();
            var faq = (Category)context.CategoryClasses.FirstOrDefault(c => c.CategoryId == GlobalConfig.FAQ && c.StatusId == GlobalConfig.Visible);
            var categories = faq.CategoryClassSubCategories.Where(c => c.SubCategory.StatusId == GlobalConfig.Visible).ToList();

            //Get Top 5
            string Top5 = GlobalConfig.FaqTop5;
            var Top5Ids = MyUtility.StringToIntList(Top5);
            var category = context.CategoryClasses.Where(c => Top5Ids.Contains(c.CategoryId) && c.StatusId == GlobalConfig.Visible).ToList();
            ViewBag.Top5Q = category;

            if (!Request.Cookies.AllKeys.Contains("version"))
            {
                try
                {
                    if (User.Identity.IsAuthenticated)
                    {
                        var UserId = new Guid(User.Identity.Name);
                        var user = context.Users.FirstOrDefault(u => u.UserId == UserId);
                        if (user != null)
                            ViewBag.EmailAddress = user.EMail;
                    }
                }
                catch (Exception) { }
                return View("Index2", categories);
            }

            return View(categories);
        }
Esempio n. 21
0
        public ActionResult Process()
        {
            if (User.Identity.IsAuthenticated)
            {
                var context = new IPTV2Entities();
                System.Guid userId = new System.Guid(User.Identity.Name);
                User user = context.Users.FirstOrDefault(u => u.UserId == userId);

                if (user != null)
                {
                    var offering = context.Offerings.Find(GlobalConfig.offeringId);
                    var registDt = DateTime.Now;

                    if (user.HasPendingGomsChangeCountryTransaction(offering))
                        return PartialView("PaymentTemplates/_BuyPendingChangeCountryErrorPartial");

                    if (user.HasExceededMaximumReloadTransactionsForTheDay(GlobalConfig.reloadTransactionMaximumThreshold, registDt))
                        return PartialView("PaymentTemplates/_BuyErrorExceededMaximumThresholdPartial");
                }

                UserWallet wallet = user.UserWallets.FirstOrDefault(w => w.Currency == MyUtility.GetCurrencyOrDefault(user.CountryCode));
                string CurrencyCode = MyUtility.GetCurrencyOrDefault(user.CountryCode);
                Currency currency = context.Currencies.FirstOrDefault(c => c.Code == CurrencyCode);
                if (currency.IsLeft)
                    ViewBag.currentBalance = String.Format("{0}{1}", currency.Symbol, wallet.Balance.ToString("F"));
                else
                    ViewBag.currentBalance = String.Format("{0}{1}", wallet.Balance.ToString("F"), currency.Symbol);
                ViewBag.currentBalance = String.Format("{0} {1}", currency.Code, wallet.Balance.ToString("F"));
                //ViewBag.CreditCardList = user.Country.GetGomsCreditCardTypes();
                //UPDATED  05/07/2013
                if (GlobalConfig.IsMECreditCardEnabled)
                {
                    try
                    {
                        if (user.Country.GomsSubsidiaryId != GlobalConfig.MiddleEastGomsSubsidiaryId)
                            ViewBag.CreditCardList = user.Country.GetGomsCreditCardTypes();
                        else
                        {
                            var listOfMiddleEastAllowedCountries = GlobalConfig.MECountriesAllowedForCreditCard.Split(','); //get list of middle east countries allowed for credit card payment
                            if (listOfMiddleEastAllowedCountries.Contains(user.Country.Code))
                                ViewBag.CreditCardList = user.Country.GetGomsCreditCardTypes();
                            else
                                ViewBag.CreditCardList = null;
                        }
                    }
                    catch (Exception) { ViewBag.CreditCardList = null; }
                }
                else
                    ViewBag.CreditCardList = user.Country.GetGomsCreditCardTypes();
                ViewBag.IsPayPalSupported = currency.IsPayPalSupported;

                return PartialView("_ReloadProcessPartial");
            }
            else
            {
                //return RedirectToAction("Index", "Home");                
                return PartialView("PaymentTemplates/_BuyAuthenticationErrorPartial");
            }
        }
Esempio n. 22
0
 public static void PpcTypeTester()
 {
     var context = new IPTV2Entities();
     var regularPpc = (SubscriptionPpc)context.Ppcs.FirstOrDefault(p => p.PpcProductId == 1002);
     var trialPpc = (SubscriptionPpc)context.Ppcs.FirstOrDefault(p => p.PpcProductId == 1090);
     var compensatoryPpc = (SubscriptionPpc)context.Ppcs.FirstOrDefault(p => p.PpcProductId == 1093);
     var complimentaryPpc = (SubscriptionPpc)context.Ppcs.FirstOrDefault(p => p.PpcProductId == 1094); 
 }
Esempio n. 23
0
        public static void GetEntitlement()
        {
            var context = new IPTV2Entities();
            var user = context.Users.First(u => u.EMail == "*****@*****.**");
            var entitlement1 = Entitlement.GetUserProductEntitlement(context, user.UserId, 1);
            var entitlement2 = Entitlement.GetUserProductEntitlement(context, user.UserId, 2);

        }
Esempio n. 24
0
        //
        // GET: /Ajax/

        public int CheckEmail(string email)
        {
            if (String.IsNullOrEmpty(email))
                return 0;
            var context = new IPTV2Entities();
            var count = context.Users.Count(item => item.EMail.ToLower() == email.ToLower());
            return count;
        }
Esempio n. 25
0
 public static void TestGroup()
 {
     var context = new IPTV2Entities();
     var productGroup = context.ProductGroups.Find(1);
     var upgradeableFromPGs = productGroup.UpgradeableFromProductGroups();
     var packageIds = productGroup.GetPackageIds(false);
     var showIds = productGroup.GetShowIds(false);
 }
Esempio n. 26
0
        private void Send(EmailInformation information)
        {
            var context = new IPTV2Entities();
            context.Database.Connection.ConnectionString = RoleEnvironment.GetConfigurationSettingValue("Iptv2Entities");
            Trace.WriteLine(context.Database.Connection.ConnectionString);
            try
            {                
                if (information.isRecurring)
                {

                    var usersWithRecurring = EmailReminder.GetRecurringUsers(context, information.numberOfDays, offeringId);
                    if (usersWithRecurring != null)
                    {
                        var emailTemplateHTML = information.Template;
                        foreach (var item in usersWithRecurring)
                        {
                            var template = emailTemplateHTML;
                            var textBody = template.Replace("[firstname]", item.User.FirstName);
                            textBody = textBody.Replace("[productname]", item.Product.Description);
                            if (item.Product is SubscriptionProduct)
                            {
                                var sproduct = (SubscriptionProduct)item.Product;
                                textBody = textBody.Replace("[newexpiry]", GetEntitlementEndDate(sproduct.Duration, sproduct.DurationType, item.EndDate.Value).ToString("MMMM dd, yyyy"));
                            }
                            Trace.TraceInformation("Trying to send email to " + item.User.EMail);
                            EmailReminder.SendEmailViaSendGrid(item.User.EMail, fromEmail, information.Subject, String.Empty, TFCtv_EMail_Reminder.MailType.TextOnly, textBody, SendGridUsername, SendGridPassword, SendGridSmtpHost, SendGridSmtpPort);
                        }
                    }
                }
                else
                {
                    var users = EmailReminder.GetUsers(context, information.numberOfDays, offeringId);
                    if (users != null)
                    {
                        var emailTemplateHTML = information.Template;
                        foreach (var user in users)
                        {
                            var template = emailTemplateHTML;
                            var htmlBody = template.Replace("[firstname]", user.FirstName);

                            var dealers = EmailReminder.GetDealerNearUser(context, user, offeringId);

                            htmlBody = htmlBody.Replace("[dealers]", dealers);

                            Trace.TraceInformation("Trying to send email to  " + user.EMail);
                            //Trace.WriteLine(htmlBody);

                            EmailReminder.SendEmailViaSendGrid(user.EMail, fromEmail, information.Subject, htmlBody, TFCtv_EMail_Reminder.MailType.HtmlOnly, String.Empty, SendGridUsername, SendGridPassword, SendGridSmtpHost, SendGridSmtpPort);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Trace.TraceInformation("Error: " + e.Message);
                Trace.TraceInformation("Inner Exception: " + e.InnerException.Message);
            }
        }
 public ActionResult Subscription()
 {
     var context = new IPTV2Entities();
     var products = context.Products.Where(item => item.GomsProductId > 0 && item.GomsProductId != null && item.GomsProductQuantity == 1);
     ViewBag.Currencies = context.Currencies;
     if (products != null)
         return View(products);
     return RedirectToAction("Index");
 }
Esempio n. 28
0
        public static void ProcessAllGomsPendingTransactionsForUser()
        {

            var context = new IPTV2Entities();
            var service = new GomsTfcTv();
            var offering = context.Offerings.Find(2);
            var user = context.Users.FirstOrDefault(u => u.EMail == "*****@*****.**");            
            service.ProcessAllPendingTransactionsInGoms(context, offering, user);
        }
Esempio n. 29
0
 public static void ChannelTest()
 {
     var context = new IPTV2Entities();
     var offering = context.Offerings.Find(2);
     var channels = context.Channels.Find(1);
     var packages = channels.GetPackageProductIds(offering, "US", RightsType.Online, false);
     var packagesCached = channels.GetPackageProductIds(offering, "US", RightsType.Online, true);
     var onlinePackages = channels.GetPackageProductIds(offering, "US", RightsType.Online, true);
 }
Esempio n. 30
0
        public static void PpcReload()
        {
            var context = new IPTV2Entities();
            var service = new GomsTfcTv();

            // get transaction
            // List<PpcReloadTransaction> ts = context.Transactions.Where(t => t is PpcReloadTransaction && t.GomsTransactionId == null).ToList();
            var trans = context.Transactions.OfType<PpcReloadTransaction>().FirstOrDefault(t => t.GomsTransactionId == null && t.ReloadPpc.PpcType.GomsSubsidiaryId == t.User.GomsSubsidiaryId);
            var resp = service.ReloadWallet(context, trans.User.UserId, trans.TransactionId);
        }