Пример #1
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" })));
        }
Пример #2
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
                }));
            }
        }