コード例 #1
0
        public ActionResult iteUnlinkAccount(FormCollection fc) //int idType, string iteId, string tfctvUserId
        {
            ITEResponseError iteRespErr = ITEResponseError.UNKNOWN_ERROR;
            var iteResp = new ITEResponse()
            {
                StatusCode = (int)ITEResponseError.UNKNOWN_ERROR,
                Message = MyUtility.getITEError(iteRespErr)
            };

            try
            {
                try
                {
                    var requestingIp = Request.GetUserHostAddressFromCloudflare();
                    var whiteListedIp = GlobalConfig.ITEWhitelistedIp.Split(',');
                    if (!whiteListedIp.Contains(requestingIp))
                    {
                        iteRespErr = ITEResponseError.IP_NOT_ALLOWED;
                        iteResp.Message = String.Format("{0},{1},{2},{3},{4}", (int)iteRespErr, iteRespErr.ToString(), String.Empty, String.Empty, String.Empty);
                        return this.Content(iteResp.Message, "plain/text");
                    }
                }
                catch (Exception) { }

                Dictionary<string, string> tmpCollection = fc.AllKeys.ToDictionary(k => k, v => fc[v]);
                bool isMissingRequiredFields = false;
                foreach (var x in tmpCollection)
                {
                    if (String.IsNullOrEmpty(x.Value))
                    {
                        isMissingRequiredFields = true;
                        break;
                    }
                }

                if (!isMissingRequiredFields) // process form
                {
                    int idType = Convert.ToInt32(fc["idType"]);
                    string iteId = fc["iteId"];
                    string tfctvUserId = fc["tfctvUserId"];

                    var registDt = DateTime.Now;
                    var context = new IPTV2Entities();
                    var user = context.Users.FirstOrDefault(u => u.UserId == new Guid(tfctvUserId));
                    if (user != null)
                    {
                        var iteDetail = user.ITEDetail;
                        if (String.Compare(iteDetail.ITEId, iteId, true) == 0)
                        {
                            //Create Cancellation Transaction
                            CancellationTransaction cancellation = new CancellationTransaction()
                            {
                                CancellationRemarks = "Unlink IT&E account",
                                GomsTransactionId = -1000,
                                GomsTransactionDate = registDt,
                                OriginalTransactionId = 0,
                                StatusId = 1,
                                OfferingId = GlobalConfig.offeringId,
                                Date = registDt,
                                Amount = 0,
                                Currency = user.Country.CurrencyCode,
                                Reference = String.Format("UNLINK IT&E ({0})", user.ITEDetail.ITEId)
                            };

                            user.Transactions.Add(cancellation);
                            context.ITEDetails.Remove(iteDetail);

                            if (context.SaveChanges() > 0)
                            {
                                iteRespErr = ITEResponseError.SUCCESS;
                                iteResp.StatusCode = (int)iteRespErr;
                                iteResp.Message = "You have unlink your IT&E account from TFC.tv";
                                iteResp.Message = String.Format("{0},{1},{2},{3},{4}", iteResp.StatusCode, iteRespErr.ToString(), String.Empty, String.Empty, String.Empty);
                                return this.Content(iteResp.Message, "plain/text");
                            }
                            else
                                iteRespErr = ITEResponseError.UNABLE_TO_COMMIT;
                        }
                        else
                            iteRespErr = ITEResponseError.ITEID_DO_NOT_MATCH;
                    }
                    else
                        iteRespErr = ITEResponseError.USER_NOT_FOUND;
                }
                else
                    iteRespErr = ITEResponseError.MISSING_PARAMETERS;

                iteResp.StatusCode = (int)iteRespErr;
                //iteResp.Message = MyUtility.getITEError(iteRespErr);
                iteResp.Message = String.Format("{0},{1},{2},{3}", iteResp.StatusCode, iteRespErr.ToString(), String.Empty, String.Empty);
            }
            catch (Exception e) { MyUtility.LogException(e); iteRespErr = ITEResponseError.UNKNOWN_ERROR; }
            //return this.Json(iteResp, JsonRequestBehavior.AllowGet);
            return this.Content(iteResp.Message, "plain/text");
        }
コード例 #2
0
        public ActionResult iteActivate(FormCollection fc) //int idType, string iteId, string tfctvUserId, string packageType, DateTime subscriptionEndDate, string comments
        {
            ITEResponseError iteRespErr = ITEResponseError.UNKNOWN_ERROR;
            var iteResp = new ITEResponse()
            {
                StatusCode = (int)ITEResponseError.UNKNOWN_ERROR,
                Message = MyUtility.getITEError(iteRespErr)
            };
            try
            {
                try
                {
                    var requestingIp = Request.GetUserHostAddressFromCloudflare();
                    var whiteListedIp = GlobalConfig.ITEWhitelistedIp.Split(',');
                    if (!whiteListedIp.Contains(requestingIp))
                    {
                        iteRespErr = ITEResponseError.IP_NOT_ALLOWED;
                        iteResp.Message = String.Format("{0},{1},{2},{3},{4}", (int)iteRespErr, iteRespErr.ToString(), String.Empty, String.Empty, String.Empty);
                        return this.Content(iteResp.Message, "plain/text");
                    }
                }
                catch (Exception) { }

                Dictionary<string, string> tmpCollection = fc.AllKeys.ToDictionary(k => k, v => fc[v]);
                bool isMissingRequiredFields = false;
                foreach (var x in tmpCollection)
                {
                    if (String.IsNullOrEmpty(x.Value))
                    {
                        isMissingRequiredFields = true;
                        break;
                    }
                }

                if (!isMissingRequiredFields) // process form
                {

                    int idType = Convert.ToInt32(fc["idType"]);
                    string iteId = fc["iteId"];
                    string tfctvUserId = fc["tfctvUserId"];
                    string packageType = fc["packageType"];
                    DateTime subscriptionEndDate = Convert.ToDateTime(fc["subscriptionEndDate"]);
                    string comments = fc["comments"];

                    IPTV2Entities context = new IPTV2Entities();
                    ITEDetail iteUser = context.ITEDetails.FirstOrDefault(i => String.Compare(i.ITEId, iteId) == 0 && String.Compare(i.UserId.ToString(), tfctvUserId) == 0);
                    //check if iteuser exists
                    if (iteUser != null)
                    {
                        int packageId = ContextHelper.GetPackageFromProductId((int)ITEPackageType.LITEPACKAGE);
                        var user = context.Users.FirstOrDefault(u => u.UserId == new Guid(tfctvUserId));
                        var packageEntitlements = user.PackageEntitlements;
                        var iteEntitlement = packageEntitlements.FirstOrDefault(p => p.PackageId == packageId);
                        //check user has free entitlement
                        if (iteEntitlement != null)
                        {
                            var errResp = PaymentHelper.PayViaWalletWithEndDate(context, user.UserId, (int)ITEPackageType.LITEPACKAGE, SubscriptionProductType.Package, user.UserId, null, subscriptionEndDate, String.Format("RENEW IT&E ({0})", user.ITEDetail.ITEId));
                            if (errResp.Code == (int)ErrorCodes.Success)
                            {
                                iteRespErr = ITEResponseError.SUCCESS;
                                iteResp.StatusCode = (int)ITEResponseError.SUCCESS;
                                //iteResp.Message = String.Format(MyUtility.getITEError(ITEResponseError.SUCCESS), ITEPackageType.LITEPACKAGE.ToString(), iteEntitlement.EndDate.ToShortDateString());
                                iteResp.Message = String.Format("{0},{1},{2},{3},{4}", iteResp.StatusCode, iteRespErr.ToString(), ITEPackageType.LITEPACKAGE.ToString(), iteEntitlement.EndDate.ToShortDateString(), user.UserId.ToString());
                                return this.Content(iteResp.Message, "plain/text");
                                //return this.Json(iteResp, JsonRequestBehavior.AllowGet);
                            }
                        }
                        else
                            iteRespErr = ITEResponseError.ACCOUNTANI_NOT_FOUND;
                    }
                    else
                        iteRespErr = ITEResponseError.ACCOUNTANI_NOT_FOUND;
                }
                else
                    iteRespErr = ITEResponseError.MISSING_PARAMETERS;

                iteResp.StatusCode = (int)iteRespErr;
                //iteResp.Message = MyUtility.getITEError(iteRespErr);
                iteResp.Message = String.Format("{0},{1},{2},{3},{4}", iteResp.StatusCode, iteRespErr.ToString(), String.Empty, String.Empty, String.Empty);
            }
            catch (Exception e) { MyUtility.LogException(e); iteRespErr = ITEResponseError.UNKNOWN_ERROR; }
            //return this.Json(iteResp, JsonRequestBehavior.AllowGet);
            return this.Content(iteResp.Message, "plain/text");
        }
コード例 #3
0
        public ActionResult iteGetUser(FormCollection fc) //int idType, string iteId
        //public ActionResult iteGetUser(int idType, string iteId) //int idType, string iteId
        {
            ITEResponseError iteRespErr = ITEResponseError.UNKNOWN_ERROR;
            var iteResp = new ITEResponse()
            {
                StatusCode = (int)ITEResponseError.UNKNOWN_ERROR,
                Message = MyUtility.getITEError(iteRespErr)
            };
            try
            {
                try
                {
                    var requestingIp = Request.GetUserHostAddressFromCloudflare();
                    var whiteListedIp = GlobalConfig.ITEWhitelistedIp.Split(',');
                    if (!whiteListedIp.Contains(requestingIp))
                    {
                        iteRespErr = ITEResponseError.IP_NOT_ALLOWED;
                        iteResp.Message = String.Format("{0},{1},{2},{3},{4},{5}", (int)iteRespErr, iteRespErr.ToString(), String.Empty, String.Empty, String.Empty, String.Empty);
                        return this.Content(iteResp.Message, "plain/text");
                    }
                }
                catch (Exception) { }

                Dictionary<string, string> tmpCollection = fc.AllKeys.ToDictionary(k => k, v => fc[v]);
                bool isMissingRequiredFields = false;
                foreach (var x in tmpCollection)
                {
                    if (String.IsNullOrEmpty(x.Value))
                    {
                        isMissingRequiredFields = true;
                        break;
                    }
                }

                if (!isMissingRequiredFields) // process form
                {
                    int idType = Convert.ToInt32(fc["idType"]);
                    string iteId = fc["iteId"];

                    IPTV2Entities context = new IPTV2Entities();
                    ITEDetail iteUser = context.ITEDetails.FirstOrDefault(i => i.ITEId == iteId);
                    //check if iteuser exists
                    if (iteUser != null)
                    {
                        int packageId = ContextHelper.GetPackageFromProductId((int)ITEPackageType.LITEPACKAGE);
                        var user = context.Users.FirstOrDefault(u => u.UserId == iteUser.UserId);
                        var packageEntitlements = user.PackageEntitlements;
                        var iteEntitlement = packageEntitlements.FirstOrDefault(p => p.PackageId == packageId);
                        //check user has free entitlement
                        if (iteEntitlement != null)
                        {
                            iteRespErr = ITEResponseError.SUCCESS;
                            iteResp.StatusCode = (int)ITEResponseError.SUCCESS;
                            //iteResp.Message = String.Format(MyUtility.getITEError(ITEResponseError.SUCCESS), ITEPackageType.LITEPACKAGE.ToString(), iteEntitlement.EndDate.ToShortDateString());
                            iteResp.Message = String.Format("{0},{1},{2},{3},{4},{5}", iteResp.StatusCode, iteRespErr.ToString(), ITEPackageType.LITEPACKAGE.ToString(), iteEntitlement.EndDate.ToShortDateString(), user.UserId.ToString(), user.EMail);
                            iteResp.tfctvUserId = iteUser.UserId.ToString();
                            iteResp.packageType = ITEPackageType.LITEPACKAGE.ToString();
                            iteResp.startDate = (DateTime)iteEntitlement.LatestEntitlementRequest.StartDate;
                            iteResp.expirationDate = iteEntitlement.EndDate;
                            return this.Content(iteResp.Message, "plain/text");
                            //return this.Json(iteResp, JsonRequestBehavior.AllowGet);
                        }
                        else
                            iteRespErr = ITEResponseError.ACCOUNTANI_NOT_FOUND;
                    }
                    else
                        iteRespErr = ITEResponseError.ACCOUNTANI_NOT_FOUND;
                }
                else
                    iteRespErr = ITEResponseError.MISSING_PARAMETERS;

                iteResp.StatusCode = (int)iteRespErr;
                iteResp.Message = String.Format("{0},{1},{2},{3},{4},{5}", iteResp.StatusCode, iteRespErr.ToString(), String.Empty, String.Empty, String.Empty, String.Empty);
            }
            catch (Exception e) { MyUtility.LogException(e); iteRespErr = ITEResponseError.UNKNOWN_ERROR; }
            return this.Content(iteResp.Message, "plain/text");
        }
コード例 #4
0
        public ActionResult iteDeactivate(FormCollection fc) //int idType, string iteId, string tfctvUserId, string packageType, DateTime deactivationDate, string reason
        {
            ITEResponseError iteRespErr = ITEResponseError.UNKNOWN_ERROR;
            var iteResp = new ITEResponse()
            {
                StatusCode = (int)ITEResponseError.UNKNOWN_ERROR,
                Message = MyUtility.getITEError(iteRespErr)
            };
            try
            {
                try
                {
                    var requestingIp = Request.GetUserHostAddressFromCloudflare();
                    var whiteListedIp = GlobalConfig.ITEWhitelistedIp.Split(',');
                    if (!whiteListedIp.Contains(requestingIp))
                    {
                        iteRespErr = ITEResponseError.IP_NOT_ALLOWED;
                        iteResp.Message = String.Format("{0},{1},{2},{3},{4}", (int)iteRespErr, iteRespErr.ToString(), String.Empty, String.Empty, String.Empty);
                        return this.Content(iteResp.Message, "plain/text");
                    }
                }
                catch (Exception) { }

                Dictionary<string, string> tmpCollection = fc.AllKeys.ToDictionary(k => k, v => fc[v]);
                bool isMissingRequiredFields = false;
                foreach (var x in tmpCollection)
                {
                    if (String.IsNullOrEmpty(x.Value))
                    {
                        isMissingRequiredFields = true;
                        break;
                    }
                }

                if (!isMissingRequiredFields) // process form
                {
                    int idType = Convert.ToInt32(fc["idType"]);
                    string iteId = fc["iteId"];
                    string tfctvUserId = fc["tfctvUserId"];
                    string packageType = fc["packageType"];
                    DateTime deactivationDate = Convert.ToDateTime(fc["deactivationDate"]);
                    string reason = fc["reason"];

                    var registDt = System.DateTime.Now;
                    IPTV2Entities context = new IPTV2Entities();
                    ITEDetail iteUser = context.ITEDetails.FirstOrDefault(i => String.Compare(i.ITEId, iteId) == 0 && String.Compare(i.UserId.ToString(), tfctvUserId) == 0);
                    //check if iteuser exists
                    if (iteUser != null)
                    {
                        int packageId = ContextHelper.GetPackageFromProductId((int)ITEPackageType.LITEPACKAGE);
                        var user = context.Users.FirstOrDefault(u => u.UserId == new Guid(tfctvUserId));
                        var iteEntitlement = user.PackageEntitlements.FirstOrDefault(p => p.PackageId == packageId);
                        int latestITEEntitlementReqId = (int)iteEntitlement.LatestEntitlementRequestId;
                        var purchaseItem = context.PurchaseItems.FirstOrDefault(p => p.EntitlementRequestId == latestITEEntitlementReqId);
                        var iteTransaction = iteUser.User.Transactions.FirstOrDefault(t => t is WalletPaymentTransaction && ((WalletPaymentTransaction)t).PurchaseId == purchaseItem.PurchaseId);

                        //check user has free entitlement
                        if (iteEntitlement != null)
                        {
                            iteEntitlement.EndDate = deactivationDate;
                            var cancellation = new CancellationTransaction()
                            {
                                CancellationRemarks = reason,
                                GomsTransactionId = -1000,
                                GomsTransactionDate = registDt,
                                OriginalTransactionId = iteTransaction != null ? iteTransaction.TransactionId : 0,
                                StatusId = 1,
                                OfferingId = GlobalConfig.offeringId,
                                Date = registDt,
                                Amount = 0,
                                Currency = purchaseItem.Currency,
                                Reference = String.Format("DEACTIVATE IT&E ({0})", user.ITEDetail.ITEId)
                            };
                            user.Transactions.Add(cancellation);
                            if (context.SaveChanges() > 0)
                            {
                                iteRespErr = ITEResponseError.SUCCESS;
                                iteResp.StatusCode = (int)ITEResponseError.SUCCESS;
                                //iteResp.Message = String.Format(MyUtility.getITEError(ITEResponseError.SUCCESS), ITEPackageType.LITEPACKAGE.ToString(), deactivationDate.ToShortDateString());
                                iteResp.Message = String.Format("{0},{1},{2},{3},{4}", iteResp.StatusCode, iteRespErr.ToString(), ITEPackageType.LITEPACKAGE.ToString(), iteEntitlement.EndDate.ToShortDateString(), user.UserId.ToString());
                                return this.Content(iteResp.Message, "plain/text");
                            }
                        }
                        else
                            iteRespErr = ITEResponseError.ACCOUNTANI_NOT_FOUND;
                    }
                    else
                        iteRespErr = ITEResponseError.ACCOUNTANI_NOT_FOUND;
                }
                else
                    iteRespErr = ITEResponseError.MISSING_PARAMETERS;

                iteResp.StatusCode = (int)iteRespErr;
                //iteResp.Message = MyUtility.getITEError(iteRespErr);
                iteResp.Message = String.Format("{0},{1},{2},{3},{4}", iteResp.StatusCode, iteRespErr.ToString(), String.Empty, String.Empty, String.Empty);
            }
            catch (Exception e) { MyUtility.LogException(e); iteRespErr = ITEResponseError.UNKNOWN_ERROR; }
            //return this.Json(iteResp, JsonRequestBehavior.AllowGet);
            return this.Content(iteResp.Message, "plain/text");
        }