Ejemplo n.º 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));
        }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 3
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);
        }
Ejemplo n.º 4
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
                }));
            }
        }