Пример #1
0
        public ActionResult AddSubscription(string textPhone, string category, string headerId)
        {
            if (!string.IsNullOrEmpty(textPhone))
            {
                if (textPhone.StartsWith("0"))
                {
                    textPhone = "234" + textPhone.TrimStart('0');
                }
                var msisdn = new MSISDNRepository();
                msisdn = (MSISDNRepository)Session["XMSISDN"];
                //if (msisdn == null)
                //    msisdn = FillMSISDN();
                //13/02/2017

                if ((MSISDNRepository)Session["XMSISDN"] != null)
                {
                    msisdn = (MSISDNRepository)Session["XMSISDN"];
                }
                else
                {
                    msisdn = _HeaderController.FillMSISDN();
                }

                var ipthis = msisdn.Lines.FirstOrDefault().IpAddress;
                msisdn.Clear();
                msisdn.AddItem(textPhone, ipthis, false);
                var newmsisdn = (MSISDNRepository)Session["XMSISDN"];
                HttpContext.Session["XMSISDN"] = msisdn;

                try
                {
                    if (msisdn != null && msisdn.Lines.Count() > 0 && msisdn.Lines.FirstOrDefault().Phone != "XXX-XXXXXXXX")
                    {
                        _ServiceRequestRepository.Subscribe(Convert.ToInt32(headerId), msisdn.Lines.FirstOrDefault().IpAddress, msisdn.Lines.FirstOrDefault().Phone, msisdn.Lines.FirstOrDefault().IsHeader);
                    }

                    //to return manual numbers here
                    else
                    {
                        return(Redirect(Url.Action("Fill", new { category = category, headerId = headerId })));
                    }

                    var newmsisdn1 = (MSISDNRepository)Session["XMSISDN"];
                }
                catch (Exception ex)
                {
                    LocalLogger.LogFileWrite(ex.Message);
                }
                if (string.IsNullOrEmpty(category))
                {
                    category = "Home";
                }
                return(Redirect(Url.Action("Index", new { controller = category, action = "Index" })));
            }
            return(Redirect(Request.Url.PathAndQuery));
        }
Пример #2
0
 public HomeController(AppUserController appUserController, IAppUserRepository AppUserRepository, IServiceHeaderRepository ServiceHeader, MSISDNRepository mSISDNRepository, HeaderController headerController, IServiceRequestRepository serviceRequestRepository, TOOLS.WapHeaderUtil wapHeaderUtil)
 {
     _AppUserRepository        = AppUserRepository;
     _AppUserController        = appUserController;
     _ServiceHeaderRpository   = ServiceHeader;
     _ServiceRequestRepository = serviceRequestRepository;
     _HeaderController         = headerController;
     _MSISDNRepository         = mSISDNRepository;
     _NGSubscriptionsEntities  = new GameData.NGSubscriptionsEntities();
     _WapHeaderUtil            = wapHeaderUtil;
 }
Пример #3
0
        public ActionResult Pay(MSISDNRepository msisdn, string category, string headerId)
        {
            //msisdn = (MSISDN)Session["XMSISDN"];

            if ((MSISDNRepository)Session["XMSISDN"] != null)
            {
                msisdn = (MSISDNRepository)Session["XMSISDN"];
            }
            else
            {
                msisdn = FillMSISDN();
            }

            try
            {
                //msisdn.Lines.FirstOrDefault().IsHeader)
                if (msisdn != null && msisdn.Lines.Count() > 0 && msisdn.Lines.FirstOrDefault().Phone != "XXX-XXXXXXXX")
                {
                    repository.Subscribe(Convert.ToInt32(headerId), msisdn.Lines.FirstOrDefault().IpAddress, msisdn.Lines.FirstOrDefault().Phone, msisdn.Lines.FirstOrDefault().IsHeader);
                }
                else
                {
                    return(Redirect(Url.Action("Fill", new { category = category, headerId = headerId })));
                }
                //if (msisdn == null || msisdn.Lines.Count() < 1 || msisdn.Lines.FirstOrDefault().Phone == "XXX-XXXXXXXX")
                //{
                //    return Redirect(Url.Action("Fill", new { category = category, headerId = headerId }));

                //}
                //else
                //{
                //    repository.Subscribe(Convert.ToInt32(headerId), msisdn.Lines.FirstOrDefault().IpAddress, msisdn.Lines.FirstOrDefault().Phone, msisdn.Lines.FirstOrDefault().IsHeader);
                //}
            }
            catch (Exception ex)
            {
                _WapHeaderUtil.LogFileWrite(ex.ToString());
            }
            if (string.IsNullOrEmpty(category))
            {
                category = "Home";
            }

            return(Redirect(Url.Action("Index", new { controller = category, action = "Index" })));
        }
Пример #4
0
        private MSISDNRepository FillMSISDN()
        {
            MSISDNRepository msisdntory     = new MSISDNRepository();
            WapHeaderUtil    _WapHeaderUtil = new WapHeaderUtil();

            msisdntory.Clear();

            string msisdn = _WapHeaderUtil.MSISDN_HEADER();

            if (msisdn == "XXX-XXXXXXXX")
            {
                msisdntory.AddItem(msisdn, WapHeaderUtil.GetIPAddress(), false);
            }
            else
            {
                msisdntory.AddItem(msisdn, WapHeaderUtil.GetIPAddress());
            }
            return(msisdntory);
        }
Пример #5
0
        public MSISDNRepository FillMSISDN()
        {
            //HTTPService.HeaderIndexSoapClient d = new HTTPService.HeaderIndexSoapClient();
            MSISDNRepository msisdntory = new MSISDNRepository();

            msisdntory.Clear();
            string msisdn = _WapHeaderUtil.MSISDN_HEADER();

            if (msisdn == "XXX-XXXXXXXX")
            {
                msisdntory.AddItem(msisdn, WapHeaderUtil.GetIPAddress(), false);
            }
            else
            {
                msisdntory.AddItem(msisdn, WapHeaderUtil.GetIPAddress());
            }


            return(msisdntory);
        }
Пример #6
0
        //protected override void Initialize()
        //{

        //}

        protected override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            System.Web.HttpContext.Current.Session["mtnNumber"] = null;
            MSISDNRepository headerData = System.Web.HttpContext.Current.Session["mtnNumber"] != null ? (MSISDNRepository)System.Web.HttpContext.Current.Session["mtnNumber"] : null;

            if (headerData == null)
            {
                headerData = FillMSISDN();
                if (headerData != null)
                {
                    new Thread(() =>
                    {
                        LocalLogger.LogFileWrite(
                            JsonConvert.SerializeObject(new VIEWMODEL.LogVM()
                        {
                            Message = "Recognised Wap Header",
                            LogData = headerData
                        }));
                    }).Start();
                }
            }
            System.Web.HttpContext.Current.Session["mtnNumber"] = headerData;
            ////===========================
            //// If session exists
            //if (filterContext.HttpContext.Session == null) return;
            ////if Not new session
            //if (!filterContext.HttpContext.Session.IsNewSession) return;
            //var cookie = filterContext.HttpContext.Request.Headers["Cookie"];
            ////if not cookie exists or sessionid index is not greater than zero
            //if ((cookie == null) || (cookie.IndexOf("ASP.NET_SessionId", StringComparison.Ordinal) < 0)) return;
            //if (filterContext.HttpContext.Request.IsAjaxRequest())
            //{
            //    filterContext.Result = RedirectToAction("SessionExpired", "Home");
            //}
            //else
            //{
            //    filterContext.HttpContext.Session.Clear(); filterContext.Result = RedirectToAction("SessionExpired", "Home");
            //}
        }
Пример #7
0
        public string MTNUSSDSubscription(long AppUserID, string MSISDN, bool IsMtn, string Shortcode, string Productcode = null, string headerId = "")
        {
            MSISDNRepository msisdn = new MSISDNRepository();
            string           ipthis = null;

            try
            {
                if (MSISDN.StartsWith("0"))
                {
                    MSISDN = "234" + MSISDN.TrimStart('0');
                }

                var subscriptionConfirm = _NGSubscriptionsEntities.ConfirmAppUserSubscription(AppUserID, MSISDN, null, Shortcode, Productcode, IsMtn).FirstOrDefault();
                //Valid Subscription Exists
                if (subscriptionConfirm.isSuccess)
                {
                    return(JsonConvert.SerializeObject(new ReturnMessage()
                    {
                        Success = false,
                        Message = "You already have an active Subscription."
                    }));
                }

                msisdn = (MSISDNRepository)Session["XMSISDN"] == null ?
                         (MSISDNRepository)System.Web.HttpContext.Current.Session["mtnNumber"] :
                         (MSISDNRepository)Session["XMSISDN"];
                HttpContext.Session["XMSISDN"] = msisdn;
                System.Web.HttpContext.Current.Session["mtnNumber"] = msisdn;

                ipthis = msisdn.Lines.FirstOrDefault().IpAddress;

                //Use Phone Number Passed
                if (!string.IsNullOrEmpty(MSISDN))
                {
                    msisdn.Clear();
                    msisdn.AddItem(MSISDN, ipthis, true);
                }

                var lineObject = msisdn.Lines.FirstOrDefault();

                var mtnNumber = (lineObject.Phone.Trim() == "XXX-XXXXXXXX") ? null : lineObject.Phone.Trim();

                if (mtnNumber == null)//Mtn number not gotten by wap header
                {
                    return(JsonConvert.SerializeObject(new ReturnMessage()
                    {
                        Success = false,
                        Message = "Subscription failed. \n Could not validate your phone number."
                    }));
                }


                if (msisdn != null && msisdn.Lines.Count() > 0 && lineObject.Phone != "XXX-XXXXXXXX")
                {
                    var subResault = _ServiceRequestRepository.Subscribe(Convert.ToInt32(headerId), lineObject.IpAddress, lineObject.Phone, lineObject.IsHeader);
                    if (subResault.Success)
                    {
                        new Thread(() =>
                        {
                            LocalLogger.LogFileWrite(
                                JsonConvert.SerializeObject(new LogVM()
                            {
                                LogData = subResault
                            }));
                        }).Start();

                        //Update User Mobile Payer Record
                        _AppUserRepository.UpdateAppUserMobilePayer(AppUserID, lineObject.Phone);

                        return(JsonConvert.SerializeObject(subResault));
                    }
                    else
                    {
                        return(JsonConvert.SerializeObject(new ReturnMessage()
                        {
                            Success = true,
                            Message = $"Subscription failed. \n {subResault.Message}"
                        }));
                    }
                }
                else
                {
                    return(JsonConvert.SerializeObject(new ReturnMessage()
                    {
                        Success = false,
                        Message = "Subscription failed. \n Could not validate your phone number."
                    }));
                }
            }
            catch (Exception ex)
            {
                new Thread(() =>
                {
                    LocalLogger.LogFileWrite(ex.Message);
                }).Start();

                return(JsonConvert.SerializeObject(new ReturnMessage()
                {
                    Success = false,
                    Message = ex.Message
                }));
            }
        }