コード例 #1
0
        public ActionResult _ClaimTVEverywhere(FormCollection fc)
        {
            Dictionary<string, object> collection = new Dictionary<string, object>();
            ErrorCodes errorCode = ErrorCodes.UnknownError;
            string errorMessage = MyUtility.getErrorMessage(ErrorCodes.UnknownError);
            collection = MyUtility.setError(errorCode, errorMessage);
            DateTime registDt = DateTime.Now;
            try
            {
                if (HasConsumedNumberOfRetriesForTFCEverywhere())
                {
                    collection = MyUtility.setError(ErrorCodes.LimitReached, "Invalid data entered. Please call our Customer Service at 18778846832 or chat with our live support team for assistance.");
                    return Content(MyUtility.buildJson(collection), "application/json");
                }
                if (((String.IsNullOrEmpty(fc["MacAddressOrSmartCard"]) && String.IsNullOrEmpty(fc["AccountNumber"]))) || String.IsNullOrEmpty(fc["ActivationNumber"]))
                {
                    collection = MyUtility.setError(ErrorCodes.IsMissingRequiredFields, "Please fill up the required fields.");
                    return Content(MyUtility.buildJson(collection), "application/json");
                }

                var context = new IPTV2Entities();
                User user = null;
                if (MyUtility.isUserLoggedIn())
                {
                    var userId = new Guid(User.Identity.Name);
                    user = context.Users.FirstOrDefault(u => u.UserId == userId);
                }
                else
                {
                    var userId = (Guid)TempData["tempUid"];
                    TempData["tempUserId"] = userId; // REASSIGN
                    TempData["tempUid"] = userId; // REASSIGN
                    user = context.Users.FirstOrDefault(u => u.UserId == userId);
                }

                if (user != null)
                {
                    string CurrencyCode = GlobalConfig.DefaultCurrency;
                    Country country = context.Countries.FirstOrDefault(c => c.Code == user.CountryCode);
                    if (country != null)
                    {
                        Currency currency = context.Currencies.FirstOrDefault(c => c.Code == country.CurrencyCode);
                        if (currency != null) CurrencyCode = currency.Code;
                    }

                    var transaction = new TfcEverywhereTransaction()
                    {
                        Amount = 0,
                        Date = DateTime.Now,
                        Currency = CurrencyCode,
                        OfferingId = GlobalConfig.offeringId,
                        StatusId = GlobalConfig.Visible,
                        Reference = "TFC Everywhere - CLAIM",
                        UserId = user.UserId
                    };

                    var gomsService = new GomsTfcTv();


                    var MacAddressOrSmartCard = fc["MacAddressOrSmartCard"].Replace(" ", "");
                    var AccountNumber = fc["AccountNumber"].Replace(" ", "");
                    var ActivationNumber = fc["ActivationNumber"].Replace(" ", "");

                    var response = gomsService.ClaimTVEverywhere(context, user.UserId, transaction, MacAddressOrSmartCard, AccountNumber, ActivationNumber);
                    if (response.IsSuccess)
                    {
                        AddTfcEverywhereEntitlement(context, response.TFCTVSubItemId, response.ExpiryDate, response.TVEServiceId, user);
                        transaction.GomsTFCEverywhereEndDate = Convert.ToDateTime(response.ExpiryDate);
                        transaction.GomsTFCEverywhereStartDate = registDt;
                        user.Transactions.Add(transaction);
                        user.IsTVEverywhere = true;
                        if (context.SaveChanges() > 0)
                        {
                            collection = MyUtility.setError(ErrorCodes.Success, String.Empty);
                            collection.Add("href", GlobalConfig.RegistrationCompleteTVE);
                        }
                    }
                    else
                    {
                        SetNumberOfTriesForTFCEverywhereCookie();
                        if (String.Compare(response.StatusCode, "8", true) == 0)
                        {
                            var sb = new StringBuilder();
                            sb.Append(response.StatusMessage);
                            sb.Append(" Go to your <a href=\"/EditProfile\" target=\"_blank\">Edit My Profile</a> page to update the last name registered on your TFC.tv account.");
                            collection = MyUtility.setError(ErrorCodes.UnknownError, sb.ToString());
                        }
                        else
                            collection = MyUtility.setError(ErrorCodes.UnknownError, response.StatusMessage);

                    }

                }
                else
                    collection = MyUtility.setError(ErrorCodes.UserDoesNotExist, "User does not exist.");
            }
            catch (Exception e) { MyUtility.LogException(e); collection = MyUtility.setError(ErrorCodes.UnknownError, e.Message); }
            return Content(MyUtility.buildJson(collection), "application/json");
        }
コード例 #2
0
        public ActionResult _RegisterTFCEverywhere(FormCollection fc)
        {
            var ReturnCode = new TransactionReturnType()
            {
                StatusCode = (int)ErrorCodes.UnknownError,
                StatusMessage = String.Empty
            };

            string url = Url.Action("RegisterTFCEverywhere", "User").ToString();
            var field_names = new string[] { "smartCardNum", "cusAccount" };
            try
            {
                if (TempData["qs"] != null)
                {
                    var qs = (NameValueCollection)TempData["qs"];
                    ViewBag.qs = qs;
                    TempData["qs"] = qs;
                }

                DateTime registDt = DateTime.Now;
                Dictionary<string, string> tmpCollection = fc.AllKeys.ToDictionary(k => k, v => fc[v]);
                bool isMissingRequiredFields = false;

                foreach (var x in tmpCollection)
                {
                    if (!field_names.Contains(x.Key))
                        if (String.IsNullOrEmpty(x.Value))
                        {
                            isMissingRequiredFields = true;
                            break;
                        }
                }

                if (!isMissingRequiredFields) // process form
                {
                    if (HasConsumedNumberOfRetriesForTFCEverywhere())
                    {
                        ReturnCode.StatusMessage = "Invalid data entered. Please call our Customer Service at 18778846832 or chat with our live support team for assistance.";
                        TempData["ErrorMessage"] = ReturnCode;
                        return RedirectToAction("RegisterTFCEverywhere", "User");
                    }

                    if (String.IsNullOrEmpty(fc["smartCardNum"]) && String.IsNullOrEmpty(fc["cusAccount"]))
                    {
                        ReturnCode.StatusMessage = "Please fill up all the required fields.";
                        TempData["ErrorMessage"] = ReturnCode;
                        return RedirectToAction("RegisterTFCEverywhere", "User");
                    }

                    var context = new IPTV2Entities();
                    User user = null;
                    if (User.Identity.IsAuthenticated)
                    {
                        string CurrencyCode = GlobalConfig.DefaultCurrency;
                        var UserId = new Guid(User.Identity.Name);
                        user = context.Users.FirstOrDefault(u => u.UserId == UserId);
                        if (user != null)
                        {
                            CurrencyCode = user.Country.CurrencyCode;

                            var transaction = new TfcEverywhereTransaction()
                            {
                                Amount = 0,
                                Date = registDt,
                                Currency = CurrencyCode,
                                OfferingId = GlobalConfig.offeringId,
                                StatusId = GlobalConfig.Visible,
                                Reference = "TFC Everywhere - CLAIM",
                                UserId = user.UserId
                            };

                            var gomsService = new GomsTfcTv();

                            var MacAddressOrSmartCard = fc["smartCardNum"].Replace(" ", "");
                            var AccountNumber = fc["cusAccount"].Replace(" ", "");
                            var ActivationNumber = fc["actCode"].Replace(" ", "");

                            var response = gomsService.ClaimTVEverywhere(context, user.UserId, transaction, MacAddressOrSmartCard, AccountNumber, ActivationNumber);
                            if (response.IsSuccess)
                            {
                                AddTfcEverywhereEntitlement(context, response.TFCTVSubItemId, response.ExpiryDate, response.TVEServiceId, user);
                                transaction.GomsTFCEverywhereEndDate = Convert.ToDateTime(response.ExpiryDate);
                                transaction.GomsTFCEverywhereStartDate = registDt;
                                user.Transactions.Add(transaction);
                                user.IsTVEverywhere = true;
                                if (context.SaveChanges() > 0)
                                {
                                    ReturnCode.StatusCode = (int)ErrorCodes.Success;
                                    ReturnCode.info = "TFC Everywhere Activation";
                                    ReturnCode.CCStatusMessage = "Congratulations! Your TFC Everywhere is now activated.";
                                    ReturnCode.StatusMessage = "Pwede ka nang manood ng piling Kapamilya shows at<br>movies mula sa paborito niyong TFC Channels.";
                                    TempData["ErrorMessage"] = ReturnCode;
                                    return RedirectToAction("Index", "Home"); // successful tve activation                                    
                                }
                            }
                            else
                            {
                                SetNumberOfTriesForTFCEverywhereCookie();
                                if (String.Compare(response.StatusCode, "8", true) == 0)
                                    ReturnCode.StatusMessage = "Go to your Edit My Profile page to update the last name registered on your TFC.tv account.";
                                else
                                    ReturnCode.StatusMessage = response.StatusMessage;
                            }
                        }
                        else
                            ReturnCode.StatusMessage = "User does not exist.";
                    }
                    else
                        ReturnCode.StatusMessage = "You are not logged in.";
                }
                else
                    ReturnCode.StatusMessage = "Please fill in all required fields.";
                TempData["ErrorMessage"] = ReturnCode;
                url = Request.UrlReferrer.AbsolutePath;
            }
            catch (Exception e) { MyUtility.LogException(e); }
            return Redirect(url);
        }
コード例 #3
0
        public ActionResult _ClaimTVE(FormCollection fc, string EmailAddress, string MacAddressOrSmartCard, string AccountNumber, string ActivationCode)
        {
            Dictionary<string, object> collection = new Dictionary<string, object>();
            ErrorCodes errorCode = ErrorCodes.UnknownError;
            string errorMessage = MyUtility.getErrorMessage(ErrorCodes.UnknownError);
            collection = MyUtility.setError(errorCode, errorMessage);

            try
            {
                DateTime registDt = DateTime.Now;

                var context = new IPTV2Entities();

                var userId = new Guid("E21D87F3-5940-451A-B7EE-ADA4F3CEC234");

                if (!String.IsNullOrEmpty(EmailAddress))
                {
                    var user = context.Users.FirstOrDefault(u => String.Compare(u.EMail, EmailAddress, true) == 0);
                    if (user != null)
                    {
                        userId = user.UserId;
                        string CurrencyCode = GlobalConfig.DefaultCurrency;
                        Country country = context.Countries.FirstOrDefault(c => c.Code == user.CountryCode);
                        if (country != null)
                        {
                            Currency currency = context.Currencies.FirstOrDefault(c => c.Code == country.CurrencyCode);
                            if (currency != null) CurrencyCode = currency.Code;
                        }

                        var transaction = new TfcEverywhereTransaction()
                        {
                            Amount = 0,
                            Date = DateTime.Now,
                            Currency = CurrencyCode,
                            OfferingId = GlobalConfig.offeringId,
                            StatusId = GlobalConfig.Visible,
                            Reference = "TFC Everywhere - Activate"
                        };

                        //string MacAddressOrSmartCard = "00172F0108FC";
                        //string AccountNumber = "US-000179857";
                        //string ActivationCode = "5S3UDP";
                        var gomsService = new GomsTfcTv();
                        var response = gomsService.ClaimTVEverywhere(context, userId, transaction, MacAddressOrSmartCard, AccountNumber, ActivationCode);
                        if (response.IsSuccess)
                        {

                            //ADD Entitlement
                            AddTfcEverywhereEntitlement(context, response.TFCTVSubItemId, response.ExpiryDate, response.TVEServiceId, user);

                            transaction.GomsTFCEverywhereEndDate = Convert.ToDateTime(response.ExpiryDate);
                            transaction.GomsTFCEverywhereStartDate = registDt;
                            user.Transactions.Add(transaction);
                            user.IsTVEverywhere = true;
                            if (context.SaveChanges() > 0)
                                collection = MyUtility.setError(ErrorCodes.Success, "Claimed TVE");
                        }
                        else
                            collection = MyUtility.setError(ErrorCodes.UnknownError, response.StatusMessage);
                    }

                }



            }
            catch (Exception e) { collection = MyUtility.setError(ErrorCodes.UserDoesNotExist, e.Message); }
            return Content(MyUtility.buildJson(collection), "application/json");

        }