Example #1
0
        [HttpGet]  // in global it is post [HttpPost]

        public async Task <ActionResult> UnSubscribe(mcmsSubscribeUser mcmssubscribeuser, string msg, string IsDevice)
        {
            //get MSISDN from header

            variable.UserPhoneNo = objCheckMsisdnUserStatus.GetHeaderWhileActionRequested(Request);

            //if header Exists

            if (variable.UserPhoneNo != null && !variable.UserPhoneNo.Equals(""))
            {
                variable.CheckResult = await SoapManager(variable.UserPhoneNo, ConstantValues.STATUS_UN_SUBSCRIBE_NAME);

                //work only has a response success- 1 or failed-0
                if (variable.CheckResult != ConstantValues.SOAP_RESPONSE_NOT_FOUND_ID)
                {
                    var resultmodel = db.objCheckSubcription.Where(t => t.UserName == variable.UserPhoneNo).ToList();

                    if (resultmodel.Count == 1)
                    {
                        if (msg == "1")
                        {
                            resultmodel[0].SelectUnsbStatus = ConstantValues.cause1;
                        }
                        else if (msg == "2")
                        {
                            resultmodel[0].SelectUnsbStatus = ConstantValues.cause2;
                        }
                        else if (msg == "3")
                        {
                            resultmodel[0].SelectUnsbStatus = ConstantValues.cause3;
                        }
                        else
                        {
                            resultmodel[0].SelectUnsbStatus = ConstantValues.cause4;
                        }

                        //check if response result is success then status will unsubscribe else status does not change

                        if (variable.CheckResult == ConstantValues.SOAP_RESPONSE_RESULT_SUCCESS_ID)
                        {
                            resultmodel[0].Status = ConstantValues.STATUS_UN_SUBSCRIBE_ID;

                            //set UnSubscribe Success Id 1 as return
                            variable.UnSubscribedResult = ConstantValues.STATUS_UNSUBSCRIBE_SUCCESS_ID; //1
                        }
                        else
                        {
                            //set UnSubscribe Success Id 1 as return
                            variable.UnSubscribedResult = ConstantValues.STATUS_UNSUBSCRIBE_FAILED_ID;  //2
                        }

                        db.SaveChanges();


                        //so check if user is Authenticate then Logged of
                        if (Request.IsAuthenticated)
                        {
                            AccountController objAccount = new AccountController();
                            variable.result = objAccount.DeviceLogOff();
                        }
                    }
                    //if User Does not in DB return UnSubscribe Failed
                    else
                    {
                        variable.UnSubscribedResult = ConstantValues.STATUS_UNSUBSCRIBE_FAILED_ID;  //2
                        //return RedirectToAction("UnSubscribeFailed");
                    }
                }
                //Response not Found 2 Unsubscribe
                else
                {
                    variable.UnSubscribedResult = ConstantValues.STATUS_UNSUBSCRIBE_FAILED_ID;
                }
            }
            //if header does not Found return Unsubscribe-2
            else
            {
                variable.UnSubscribedResult = ConstantValues.STATUS_UNSUBSCRIBE_FAILED_ID;
            }


            return(Json(new { variable.UnSubscribedResult }, JsonRequestBehavior.AllowGet));
        }