public HttpResponseMessage Get(string productId, string month, string price, string toProductId)
        {
            HttpResponseMessage  message  = null;
            defaultResponseModel response = new defaultResponseModel();
            string token = HttpContext.Current.Request.Headers["Authorization"].Replace("Bearer ", "").Trim();

            try
            {
                if (dbconn.idbCheck(out dbres))
                {
                    string userCardNo  = string.Empty;
                    string userAdminNo = string.Empty;
                    if (dbconn.checkToken(token, out userCardNo, out userAdminNo))
                    {
                        string resMon = string.Empty;
                        string resEng = string.Empty;
                        string resCry = string.Empty;

                        if (dbconn.upgradeProductByCounter(userCardNo, userAdminNo, productId, toProductId, price, month, out resEng, out resMon, out resCry))
                        {
                            response.isSuccess     = true;
                            response.resultCode    = HttpStatusCode.OK.ToString();
                            response.resultMessage = resMon;
                        }
                        else
                        {
                            response.isSuccess     = false;
                            response.resultCode    = HttpStatusCode.NotFound.ToString();
                            response.resultMessage = resMon;
                        }
                    }
                    else
                    {
                        response.isSuccess     = false;
                        response.resultCode    = HttpStatusCode.Unauthorized.ToString();
                        response.resultMessage = appConstantValues.MSG_EXPIRED;
                    }
                }
                else
                {
                    response.isSuccess     = false;
                    response.resultCode    = HttpStatusCode.NotFound.ToString();
                    response.resultMessage = appConstantValues.MSG_INTERNAL_ERROR;
                    LogWriter._error(TAG, dbres);
                }
            }
            catch (Exception ex)
            {
                response.isSuccess     = false;
                response.resultCode    = HttpStatusCode.NotFound.ToString();
                response.resultMessage = ex.Message;
                exceptionManager.ManageException(ex, TAG);
            }
            message = Request.CreateResponse(HttpStatusCode.OK, response);
            string req = string.Format(@"PRODUCT: [{0}], MONTH: [{1}], PRICE: [{2}], TOPRODUCTID: [{3}]", productId, month, price, toProductId);

            LogWriter._upgradeProduct(TAG, string.Format("IP: [{0}], Request: [{1}], Response: [{2}], Token: [{3}]", httpUtil.GetClientIPAddress(HttpContext.Current.Request), req, serializer.Serialize(response), token));
            return(message);
        }
        public async Task <HttpResponseMessage> GetRead(string nofitId)
        {
            HttpResponseMessage message = new HttpResponseMessage();
            string token = HttpContext.Current.Request.Headers["Authorization"].Replace("Bearer ", "").Trim();
            defaultResponseModel response = new defaultResponseModel();

            LogWriter._noti(TAG, string.Format(@"[>>] Request Token: [{0}], NotifId: [{1}]", token, nofitId));
            try
            {
                if (dbconn.idbCheck(out dbres))
                {
                    string userCardNo  = string.Empty;
                    string userAdminNo = string.Empty;
                    if (dbconn.checkToken(token, out userCardNo, out userAdminNo))
                    {
                        string res = dbconn.iDBCommand(appServiceQry.setReadList(nofitId, userCardNo));
                        if (res.Contains("FFFFx["))
                        {
                            response.isSuccess     = false;
                            response.resultCode    = HttpStatusCode.NotFound.ToString();
                            response.resultMessage = appConstantValues.MSG_INTERNAL_ERROR;
                        }
                        else
                        {
                            response.isSuccess     = true;
                            response.resultCode    = HttpStatusCode.OK.ToString();
                            response.resultMessage = "success";
                        }
                    }
                    else
                    {
                        response.isSuccess     = false;
                        response.resultCode    = HttpStatusCode.Unauthorized.ToString();
                        response.resultMessage = appConstantValues.MSG_EXPIRED;
                    }
                }
                else
                {
                    response.isSuccess     = false;
                    response.resultCode    = HttpStatusCode.NotFound.ToString();
                    response.resultMessage = appConstantValues.MSG_INTERNAL_ERROR;
                    LogWriter._error(TAG, dbres);
                }
            }
            catch (Exception ex)
            {
                exceptionManager.ManageException(ex, TAG);
                response.isSuccess     = false;
                response.resultCode    = HttpStatusCode.NotFound.ToString();
                response.resultMessage = appConstantValues.MSG_INTERNAL_ERROR;
            }
            message = Request.CreateResponse(HttpStatusCode.OK, response);
            LogWriter._noti(TAG, string.Format("[<<] IP: [{0}], Request: [{1}], Response: [{2}], Token: [{3}]", httpUtil.GetClientIPAddress(HttpContext.Current.Request), "", serializer.Serialize(response), token));
            return(message);
        }
Esempio n. 3
0
        public HttpResponseMessage Get()
        {
            HttpResponseMessage  message  = null;
            defaultResponseModel response = new defaultResponseModel();

            LogWriter._other(TAG, "[>>] Request");
            string token = HttpContext.Current.Request.Headers["Authorization"].Replace("Bearer ", "").Trim();

            try
            {
                if (dbconn.idbCheck(out dbres))
                {
                    string userCardNo  = string.Empty;
                    string userAdminNo = string.Empty;
                    if (dbconn.checkToken(token, out userCardNo, out userAdminNo))
                    {
                        if (dbconn.refreshSC(userAdminNo))
                        {
                            response.isSuccess     = true;
                            response.resultCode    = HttpStatusCode.OK.ToString();
                            response.resultMessage = appConstantValues.MSG_SUCCESS;
                        }
                        else
                        {
                            response.isSuccess     = false;
                            response.resultCode    = HttpStatusCode.NotFound.ToString();
                            response.resultMessage = "Идэвхжүүлэлт авах хязгаар хэтэрсэн байна.";
                        }
                    }
                    else
                    {
                        response.isSuccess     = false;
                        response.resultCode    = HttpStatusCode.Unauthorized.ToString();
                        response.resultMessage = appConstantValues.MSG_EXPIRED;
                    }
                }
                else
                {
                    response.isSuccess     = false;
                    response.resultCode    = HttpStatusCode.NotFound.ToString();
                    response.resultMessage = appConstantValues.MSG_INTERNAL_ERROR;
                    LogWriter._error(TAG, dbres);
                }
            }
            catch (Exception ex)
            {
                exceptionManager.ManageException(ex, TAG);
                response.isSuccess     = false;
                response.resultCode    = HttpStatusCode.NotFound.ToString();
                response.resultMessage = appConstantValues.MSG_INTERNAL_ERROR;
            }
            message = Request.CreateResponse(HttpStatusCode.OK, response);
            LogWriter._other(TAG, string.Format("[<<] IP: [{0}], Response: [{1}], Token: [{2}]", httpUtil.GetClientIPAddress(HttpContext.Current.Request), serializer.Serialize(response), token));
            return(message);
        }
Esempio n. 4
0
        public async Task <HttpResponseMessage> GetRegisterFbUser(string cardOrAdmin, string fbId)
        {
            LogWriter._login(TAG, string.Format(@"[>>] REQUEST: [CARD:{0}, FBID:{1}]", cardOrAdmin, fbId));
            HttpResponseMessage  message  = new HttpResponseMessage();
            defaultResponseModel response = new defaultResponseModel();
            string token = HttpContext.Current.Request.Headers["Authorization"].Replace("Bearer ", "").Trim();

            try
            {
                if (dbconn.idbCheck(out dbres))
                {
                    string userCardNo  = string.Empty;
                    string userAdminNo = string.Empty;
                    if (dbconn.checkToken(token, out userCardNo, out userAdminNo))
                    {
                        string res = dbconn.iDBCommand(appServiceQry._registerFBUser(userCardNo, userAdminNo, fbId));
                        if (res.Contains("FFFFx["))
                        {
                            response.isSuccess     = false;
                            response.resultCode    = HttpStatusCode.NotFound.ToString();
                            response.resultMessage = "Хэрэглэгч бүртгэж чадсангүй.";
                        }
                        else
                        {
                            response.isSuccess     = true;
                            response.resultCode    = HttpStatusCode.OK.ToString();
                            response.resultMessage = appConstantValues.MSG_SUCCESS;
                        }
                    }
                    else
                    {
                        response.isSuccess     = false;
                        response.resultCode    = HttpStatusCode.Unauthorized.ToString();
                        response.resultMessage = appConstantValues.MSG_EXPIRED;
                    }
                }
                else
                {
                    response.isSuccess     = false;
                    response.resultCode    = HttpStatusCode.NotFound.ToString();
                    response.resultMessage = appConstantValues.MSG_INTERNAL_ERROR;
                    LogWriter._error(TAG, dbres);
                }
            }
            catch (Exception ex)
            {
                exceptionManager.ManageException(ex, TAG);
                response.isSuccess     = false;
                response.resultCode    = HttpStatusCode.NotFound.ToString();
                response.resultMessage = appConstantValues.MSG_INTERNAL_ERROR;
            }
            message = Request.CreateResponse(HttpStatusCode.OK, response);
            LogWriter._login(TAG, string.Format(@"[<<] RESPONSE: [{0}]", serializer.Serialize(response)));
            return(message);
        }
Esempio n. 5
0
        public HttpResponseMessage Post([FromBody] registerClientTokenModel cjson)
        {
            LogWriter._login(TAG, string.Format("[>>] REQUEST: [{0}]", serializer.Serialize(cjson)));
            HttpResponseMessage  message  = null;
            defaultResponseModel response = new defaultResponseModel();
            string token = HttpContext.Current.Request.Headers["Authorization"].Replace("Bearer ", "").Trim();

            try
            {
                if (dbconn.idbCheck(out dbres))
                {
                    string userCardNo  = string.Empty;
                    string userAdminNo = string.Empty;
                    if (dbconn.checkToken(token, out userCardNo, out userAdminNo))
                    {
                        if (dbconn.registerClientToken(userCardNo, userAdminNo, cjson.clientToken))
                        {
                            response.isSuccess     = true;
                            response.resultCode    = HttpStatusCode.OK.ToString();
                            response.resultMessage = "success";
                        }
                        else
                        {
                            response.isSuccess     = false;
                            response.resultCode    = HttpStatusCode.NotFound.ToString();
                            response.resultMessage = appConstantValues.MSG_INTERNAL_ERROR;
                        }
                    }
                    else
                    {
                        response.isSuccess     = false;
                        response.resultCode    = HttpStatusCode.Unauthorized.ToString();
                        response.resultMessage = appConstantValues.MSG_EXPIRED;
                    }
                }
                else
                {
                    response.isSuccess     = false;
                    response.resultCode    = HttpStatusCode.NotFound.ToString();
                    response.resultMessage = appConstantValues.MSG_INTERNAL_ERROR;
                    LogWriter._error(TAG, dbres);
                }
            }
            catch (Exception ex)
            {
                exceptionManager.ManageException(ex, TAG);
                response.isSuccess     = false;
                response.resultCode    = HttpStatusCode.NotFound.ToString();
                response.resultMessage = appConstantValues.MSG_INTERNAL_ERROR;
            }
            message = Request.CreateResponse(HttpStatusCode.OK, response);
            LogWriter._login(TAG, string.Format("[<<] IP: [{0}], Response: [{1}], Token: [{2}]", httpUtil.GetClientIPAddress(HttpContext.Current.Request), serializer.Serialize(response), token));
            return(message);
        }
Esempio n. 6
0
        public async Task <HttpResponseMessage> GetInvoice(string sourceName)
        {
            HttpResponseMessage  message  = new HttpResponseMessage();
            defaultResponseModel response = new defaultResponseModel();

            LogWriter._qPay(TAG, string.Format(@"[>>] Request: ({0}), ", sourceName));
            string token = HttpContext.Current.Request.Headers["Authorization"].Replace("Bearer ", "").Trim();

            try
            {
                if (token == "YGHM9SHBC81LMR4G")
                {
                    string genInvoice = string.Empty;
                    switch (sourceName)
                    {
                    case "18":
                        genInvoice = convertors.generateInvoiceNo("1");
                        break;

                    case "26":
                        genInvoice = convertors.generateInvoiceNo("3");
                        break;

                    case "34":
                        genInvoice = convertors.generateInvoiceNo("5");
                        break;

                    default:
                        genInvoice = string.Empty;
                        break;
                    }

                    response.isSuccess     = true;
                    response.resultCode    = HttpStatusCode.OK.ToString();
                    response.resultMessage = genInvoice;
                }
                else
                {
                    response.isSuccess     = false;
                    response.resultCode    = HttpStatusCode.Unauthorized.ToString();
                    response.resultMessage = appConstantValues.MSG_EXPIRED;
                }
            }
            catch (Exception ex)
            {
                response.isSuccess     = false;
                response.resultCode    = HttpStatusCode.NotFound.ToString();
                response.resultMessage = ex.Message;
                exceptionManager.ManageException(ex, TAG);
            }
            message = Request.CreateResponse(HttpStatusCode.OK, response);
            LogWriter._qPay(TAG, string.Format("[<<] IP: [{0}], Response: [{1}]", httpUtil.GetClientIPAddress(HttpContext.Current.Request), serializer.Serialize(response)));
            return(message);
        }
Esempio n. 7
0
        public HttpResponseMessage GetCType()
        {
            HttpResponseMessage  message  = new HttpResponseMessage();
            defaultResponseModel response = new defaultResponseModel();
            string token = HttpContext.Current.Request.Headers["Authorization"].Replace("Bearer ", "").Trim();

            LogWriter._userInfo(TAG, string.Format("[>>] Token: [{0}]", token));
            try
            {
                if (dbconn.idbCheck(out dbres))
                {
                    string userCardNo  = string.Empty;
                    string userAdminNo = string.Empty;
                    if (dbconn.checkToken(token, out userCardNo, out userAdminNo))
                    {
                        if (checkCustomType(userCardNo))
                        {
                            response.isSuccess     = true;
                            response.resultCode    = HttpStatusCode.OK.ToString();
                            response.resultMessage = appConstantValues.MSG_SUCCESS;
                        }
                        else
                        {
                            response.isSuccess     = false;
                            response.resultCode    = HttpStatusCode.NotAcceptable.ToString();
                            response.resultMessage = "Дараа төлбөрт хэрэглэгч тул ашиглах боломжгүй.";
                        }
                    }
                    else
                    {
                        response.isSuccess     = false;
                        response.resultCode    = HttpStatusCode.Unauthorized.ToString();
                        response.resultMessage = appConstantValues.MSG_EXPIRED;
                    }
                }
                else
                {
                    response.isSuccess     = false;
                    response.resultCode    = HttpStatusCode.NotFound.ToString();
                    response.resultMessage = dbres;
                }
            }
            catch (Exception ex)
            {
                response.isSuccess     = false;
                response.resultCode    = HttpStatusCode.NotFound.ToString();
                response.resultMessage = ex.Message;
                exceptionManager.ManageException(ex, TAG);
            }
            message = Request.CreateResponse(HttpStatusCode.OK, response);
            LogWriter._userInfo(TAG, string.Format(@"[<<] Response: [{0}]", serialzer.Serialize(response)));
            return(message);
        }
Esempio n. 8
0
        public HttpResponseMessage GetSaveFBId(string adminNo, string facebookId)
        {
            LogWriter._chatBot(TAG, string.Format(@"[>>] Request: [{0}], FacebookId: [{1}]", adminNo, facebookId));
            HttpResponseMessage  message  = new HttpResponseMessage();
            defaultResponseModel response = new defaultResponseModel();
            string token = HttpContext.Current.Request.Headers["Authorization"].Replace("Bearer ", "").Trim();

            try
            {
                if (token == "YGHM9SHBC81LMR4G")
                {
                    if (dbconn.idbCheck(out dbres))
                    {
                        string res = dbconn.iDBCommand(chatbotQry._saveFbId(facebookId, adminNo));
                        if (res.Contains("FFFFx["))
                        {
                            response.isSuccess     = false;
                            response.resultCode    = HttpStatusCode.NotFound.ToString();
                            response.resultMessage = "Could not save facebook id.";
                        }
                        else
                        {
                            response.isSuccess     = true;
                            response.resultCode    = HttpStatusCode.OK.ToString();
                            response.resultMessage = appConstantValues.MSG_SUCCESS;
                        }
                    }
                    else
                    {
                        response.isSuccess     = false;
                        response.resultCode    = HttpStatusCode.NotFound.ToString();
                        response.resultMessage = appConstantValues.MSG_INTERNAL_ERROR;
                    }
                }
                else
                {
                    response.isSuccess     = false;
                    response.resultCode    = HttpStatusCode.Unauthorized.ToString();
                    response.resultMessage = appConstantValues.MSG_EXPIRED;
                }
            }
            catch (Exception ex)
            {
                exceptionManager.ManageException(ex, TAG);
                response.isSuccess     = false;
                response.resultCode    = HttpStatusCode.NotFound.ToString();
                response.resultMessage = ex.Message;
            }
            message = Request.CreateResponse(HttpStatusCode.OK, response);
            LogWriter._chatBot(TAG, string.Format("[<<] IP: [{0}], Response: [{1}], Token: [{2}]", httpUtil.GetClientIPAddress(HttpContext.Current.Request), serialzer.Serialize(response), token));
            return(message);
        }
Esempio n. 9
0
        public async Task <HttpResponseMessage> Get(string invoiceId)
        {
            HttpResponseMessage  message  = new HttpResponseMessage();
            defaultResponseModel response = new defaultResponseModel();

            LogWriter._qPay(TAG, string.Format(@"[>>] Request: ({0}), ", invoiceId));
            try
            {
                if (dbconn.idbCheck(out dbres))
                {
                    string commandResult = string.Empty;
                    bool   cmp           = completeTrans(invoiceId, out commandResult);
                    if (cmp)
                    {
                        string cmdRes = dbconn.iDBCommand(appServiceQry.updateInvTrans(invoiceId));
                        LogWriter._qPay(TAG, string.Format("Update Command Ressult: [{0}]", cmdRes));
                    }
                    response.isSuccess     = cmp;
                    response.resultCode    = HttpStatusCode.OK.ToString();
                    response.resultMessage = commandResult;
                }
                else
                {
                    response.isSuccess     = false;
                    response.resultCode    = HttpStatusCode.NotFound.ToString();
                    response.resultMessage = appConstantValues.MSG_INTERNAL_ERROR;
                    LogWriter._error(TAG, dbres);
                }
            }
            catch (Exception ex)
            {
                response.isSuccess     = false;
                response.resultCode    = HttpStatusCode.NotFound.ToString();
                response.resultMessage = ex.Message;
                exceptionManager.ManageException(ex, TAG);
            }
            message = Request.CreateResponse(HttpStatusCode.OK, response);
            LogWriter._qPay(TAG, string.Format("[<<] IP: [{0}], Response: [{1}]", httpUtil.GetClientIPAddress(HttpContext.Current.Request), serializer.Serialize(response)));
            return(message);
        }
Esempio n. 10
0
        public async Task <HttpResponseMessage> Get(string productId, string smsCode, string inDate, string amount)
        {
            HttpResponseMessage  message  = new HttpResponseMessage();
            defaultResponseModel response = new defaultResponseModel();
            upointCheckRequest   upoint   = new upointCheckRequest();
            string token = HttpContext.Current.Request.Headers["Authorization"].Replace("Bearer ", "").Trim();
            string req   = string.Format(@"AMOUNT: [{0}], PRODUCT_ID: [{1}], SMSCODE: [{2}], IN_DATE: [{3}]", amount, productId, smsCode, inDate);

            LogWriter._chargeProd(TAG, string.Format(@"[>>] Request: ({0}), ", req));
            try
            {
                if (dbconn.idbCheck(out dbres))
                {
                    string userCardNo  = string.Empty;
                    string userAdminNo = string.Empty;

                    if (dbconn.checkToken(token, out userCardNo, out userAdminNo))
                    {
                        if (checkCustomType(userCardNo))
                        {
                            upoint.card_number = userCardNo;
                            upoint.mobile      = "";
                            int    sttCode = 0;
                            string resp    = string.Empty;
                            string reqst   = serializer.Serialize(upoint);
                            if (httpWorker.http_POST("http://192.168.10.136/api/check_info", reqst, out sttCode, out resp))
                            {
                                LogWriter._error(TAG, string.Format(@"request: {0}, response: {1}", reqst, resp.Replace("\"{", "{").Replace("}\"", "}").Replace("\\", "")));
                                if (resp.Length > 5)
                                {
                                    string           chresp = resp.Replace("\"{", "{").Replace("}\"", "}").Replace("\\", "");
                                    upointCheckModel upnt   = serializer.Deserialize <upointCheckModel>(chresp);
                                    if (upnt.result == 0)
                                    {
                                        DataTable dt    = dbconn.getTable("SELECT UNI_DISH.SEQ_TRANSACTION.NEXTVAL as TRANSID FROM DUAL");
                                        string    trnId = dt.Rows[0]["TRANSID"].ToString();
                                        upointTransactionRequest utrans = new upointTransactionRequest();
                                        utrans.card_number  = userCardNo;
                                        utrans.mobile       = "";
                                        utrans.spend_amount = int.Parse(amount);
                                        utrans.total_amount = amount;
                                        utrans.cash_amount  = int.Parse(amount);
                                        utrans.regdate      = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
                                        utrans.trans_id     = trnId;
                                        List <Item> items = new List <Item>();
                                        List <Bank> banks = new List <Bank>();
                                        utrans.bank = banks;
                                        Item item = new Item();
                                        item.name        = "Данс цэнэглэх үйлчилгээ";
                                        item.code        = "8";
                                        item.unit        = "ш";
                                        item.quantity    = "1";
                                        item.total_price = amount;
                                        item.price       = amount;
                                        items.Add(item);
                                        utrans.items = items;
                                        int    sttCode1 = 0;
                                        string resp1    = string.Empty;

                                        string jjson = serializer.Serialize(utrans);
                                        if (httpWorker.http_POST("http://192.168.10.136/api/Transaction", jjson, out sttCode1, out resp1))
                                        {
                                            LogWriter._error(TAG, string.Format(@"request: {0}, response: {1}", jjson, resp1));
                                            upointTransResponse transResponse = serializer.Deserialize <upointTransResponse>(resp1);
                                            if (transResponse.issuccess == "true")
                                            {
                                                string desc = string.Format(@"[Charge Account] Mobile App upoint");
                                                if (dbconn.chargeAccountInTrans(userCardNo, amount, userAdminNo, desc, trnId))
                                                {
                                                    //response.isSuccess = true;
                                                    //response.resultCode = HttpStatusCode.OK.ToString();
                                                    //response.resultMessage = string.Format(@"Таны үндсэн данс Upoint оноогоор амжилттай цэнэглэгдлээ. Таны upoint онооны үлдэгдэл {0} байна.", transResponse.point_balance);
                                                    string resMon = string.Empty;
                                                    string resEng = string.Empty;
                                                    string resCry = string.Empty;
                                                    if (dbconn.addNvodByCounter(userCardNo, userAdminNo, inDate, smsCode, productId, out resEng, out resMon, out resCry))
                                                    {
                                                        response.isSuccess     = true;
                                                        response.resultCode    = HttpStatusCode.OK.ToString();
                                                        response.resultMessage = resMon;
                                                    }
                                                    else
                                                    {
                                                        response.isSuccess     = false;
                                                        response.resultCode    = HttpStatusCode.NotFound.ToString();
                                                        response.resultMessage = resMon;
                                                    }
                                                }
                                                else
                                                {
                                                    response.isSuccess     = false;
                                                    response.resultCode    = HttpStatusCode.Conflict.ToString();
                                                    response.resultMessage = "Данс цэнэглэхэд алдаа гарлаа";
                                                }
                                            }
                                            else
                                            {
                                                response.isSuccess     = false;
                                                response.resultCode    = HttpStatusCode.NotFound.ToString();
                                                response.resultMessage = "Upoint-с зарцуулалт хийхэд алдаа гарлаа.";
                                            }
                                        }
                                        else
                                        {
                                            response.isSuccess     = false;
                                            response.resultCode    = HttpStatusCode.NotFound.ToString();
                                            response.resultMessage = "Upoint-с зарцуулалт хийхэд алдаа гарлаа.";
                                        }
                                    }
                                    else
                                    {
                                        response.isSuccess     = false;
                                        response.resultCode    = HttpStatusCode.NotFound.ToString();
                                        response.resultMessage = "Upoint хэрэглэгч олдсонгүй.";
                                    }
                                }
                                else
                                {
                                    response.isSuccess     = false;
                                    response.resultCode    = HttpStatusCode.NotFound.ToString();
                                    response.resultMessage = "Upoint хэрэглэгч олдсонгүй.";
                                }
                            }
                            else
                            {
                                response.isSuccess     = false;
                                response.resultCode    = HttpStatusCode.NotFound.ToString();
                                response.resultMessage = "Хэрэглэгч шалгахад алдаа гарлаа.";
                            }
                        }
                        else
                        {
                            response.isSuccess     = false;
                            response.resultCode    = HttpStatusCode.NotFound.ToString();
                            response.resultMessage = "Дараа төлбөрт хэрэглэгч данс цэнэглэх боломжгүй.";
                        }
                    }
                    else
                    {
                        response.isSuccess     = false;
                        response.resultCode    = HttpStatusCode.Unauthorized.ToString();
                        response.resultMessage = appConstantValues.MSG_EXPIRED;
                    }
                }
                else
                {
                    response.isSuccess     = false;
                    response.resultCode    = HttpStatusCode.NotFound.ToString();
                    response.resultMessage = appConstantValues.MSG_INTERNAL_ERROR;
                    LogWriter._error(TAG, dbres);
                }
            }
            catch (Exception ex)
            {
                response.isSuccess     = false;
                response.resultCode    = HttpStatusCode.NotFound.ToString();
                response.resultMessage = ex.Message;
                exceptionManager.ManageException(ex, TAG);
            }
            message = Request.CreateResponse(HttpStatusCode.OK, response);
            LogWriter._chargeProd(TAG, string.Format("[<<] IP: [{0}], Response: [{1}], Token: [{2}]", httpUtil.GetClientIPAddress(HttpContext.Current.Request), serializer.Serialize(response), token));
            return(message);
        }
Esempio n. 11
0
        public async Task <HttpResponseMessage> Get(string productId, string month)
        {
            HttpResponseMessage  message  = null;
            defaultResponseModel response = new defaultResponseModel();
            string token = HttpContext.Current.Request.Headers["Authorization"].Replace("Bearer ", "").Trim();

            try
            {
                if (dbconn.idbCheck(out dbres))
                {
                    string userCardNo  = string.Empty;
                    string userAdminNo = string.Empty;

                    if (dbconn.checkToken(token, out userCardNo, out userAdminNo))
                    {
                        string resMon = string.Empty;
                        string resEng = string.Empty;
                        string resCry = string.Empty;
                        if (checkCustomType(userCardNo))
                        {
                            if (productId != "86")
                            {
                                if (dbconn.chargeProductByCounter(userCardNo, productId, month, userAdminNo, out resEng, out resMon, out resCry))
                                {
                                    response.isSuccess     = true;
                                    response.resultCode    = HttpStatusCode.OK.ToString();
                                    response.resultMessage = resMon;
                                }
                                else
                                {
                                    response.isSuccess     = false;
                                    response.resultCode    = HttpStatusCode.NotFound.ToString();
                                    response.resultMessage = resMon;
                                }
                            }
                            else
                            {
                                DataTable dtZ = dbconn.getTable(appServiceQry.checkZuslanProduct(userCardNo));
                                if (dtZ.Rows.Count != 0)
                                {
                                    response.isSuccess     = false;
                                    response.resultCode    = HttpStatusCode.NotFound.ToString();
                                    response.resultMessage = "Та Зуслан багцыг идэвхжүүлсэн байна.";
                                }
                                else
                                {
                                    if (dbconn.chargeProductByCounter(userCardNo, productId, "3", userAdminNo, out resEng, out resMon, out resCry))
                                    {
                                        response.isSuccess     = true;
                                        response.resultCode    = HttpStatusCode.OK.ToString();
                                        response.resultMessage = resMon;
                                    }
                                    else
                                    {
                                        response.isSuccess     = false;
                                        response.resultCode    = HttpStatusCode.NotFound.ToString();
                                        response.resultMessage = resMon;
                                    }
                                }
                            }
                        }
                        else
                        {
                            response.isSuccess     = false;
                            response.resultCode    = HttpStatusCode.NotFound.ToString();
                            response.resultMessage = "Дараа төлбөрт хэрэглэгч багц сунгах боломжгүй.";
                        }
                    }
                    else
                    {
                        response.isSuccess     = false;
                        response.resultCode    = HttpStatusCode.Unauthorized.ToString();
                        response.resultMessage = appConstantValues.MSG_EXPIRED;
                    }
                }
                else
                {
                    response.isSuccess     = false;
                    response.resultCode    = HttpStatusCode.NotFound.ToString();
                    response.resultMessage = appConstantValues.MSG_INTERNAL_ERROR;
                    LogWriter._error(TAG, dbres);
                }
            }
            catch (Exception ex)
            {
                response.isSuccess     = false;
                response.resultCode    = HttpStatusCode.NotFound.ToString();
                response.resultMessage = ex.Message;
                exceptionManager.ManageException(ex, TAG);
            }
            message = Request.CreateResponse(HttpStatusCode.OK, response);
            string req = string.Format(@"PRODUCT: [{0}], MONTH: [{1}]", productId, month);

            LogWriter._chargeProd(TAG, string.Format("IP: [{0}], Request: [{1}], Response: [{2}], Token: [{3}]", httpUtil.GetClientIPAddress(HttpContext.Current.Request), req, serializer.Serialize(response), token));
            return(message);
        }
Esempio n. 12
0
        public async Task <HttpResponseMessage> Get(string productId, string smsCode, string inDate)
        {
            HttpResponseMessage  message  = null;
            defaultResponseModel response = new defaultResponseModel();
            string token = HttpContext.Current.Request.Headers["Authorization"].Replace("Bearer ", "").Trim();

            try
            {
                if (dbconn.idbCheck(out dbres))
                {
                    string userCardNo  = string.Empty;
                    string userAdminNo = string.Empty;
                    if (dbconn.checkToken(token, out userCardNo, out userAdminNo))
                    {
                        string resMon = string.Empty;
                        string resEng = string.Empty;
                        string resCry = string.Empty;
                        if (checkCustomType(userCardNo))
                        {
                            if (dbconn.addNvodByCounter(userCardNo, userAdminNo, inDate, smsCode, productId, out resEng, out resMon, out resCry))
                            {
                                response.isSuccess     = true;
                                response.resultCode    = HttpStatusCode.OK.ToString();
                                response.resultMessage = resMon;
                            }
                            else
                            {
                                response.isSuccess     = false;
                                response.resultCode    = HttpStatusCode.NotFound.ToString();
                                response.resultMessage = resMon;
                            }
                        }
                        else
                        {
                            response.isSuccess     = false;
                            response.resultCode    = HttpStatusCode.NotFound.ToString();
                            response.resultMessage = "Дараа төлбөрт хэрэглэгч захиалга хийх боломжгүй.";
                        }
                    }
                    else
                    {
                        response.isSuccess     = false;
                        response.resultCode    = HttpStatusCode.Unauthorized.ToString();
                        response.resultMessage = appConstantValues.MSG_EXPIRED;
                    }
                }
                else
                {
                    response.isSuccess     = false;
                    response.resultCode    = HttpStatusCode.NotFound.ToString();
                    response.resultMessage = appConstantValues.MSG_INTERNAL_ERROR;
                    LogWriter._error(TAG, dbres);
                }
            }
            catch (Exception ex)
            {
                response.isSuccess     = false;
                response.resultCode    = HttpStatusCode.NotFound.ToString();
                response.resultMessage = ex.Message;
                exceptionManager.ManageException(ex, TAG);
            }
            message = Request.CreateResponse(HttpStatusCode.OK, response);
            string req = string.Format(@"PRODUCT: [{0}], SMSCODE: [{1}], INDATE: [{2}]", productId, smsCode, inDate);

            LogWriter._addNvod(TAG, string.Format("IP: [{0}], Request: [{1}], Response: [{2}], Token: [{3}]", httpUtil.GetClientIPAddress(HttpContext.Current.Request), req, serializer.Serialize(response), token));
            return(message);
        }
Esempio n. 13
0
        public HttpResponseMessage GetUpgrade(string toProductId, string accept)
        {
            LogWriter._upgradeProduct(TAG, string.Format("[>>]  Request toProduct: [{0}], Accept: [{1}]", toProductId, accept));
            HttpResponseMessage  message  = null;
            defaultResponseModel response = new defaultResponseModel();
            string token = HttpContext.Current.Request.Headers["Authorization"].Replace("Bearer ", "").Trim();

            try
            {
                string payType = string.Empty;
                switch (accept)
                {
                case "yes":
                    payType = "1";
                    // Виртуал данснаас зарцуулалт хийх
                    break;

                case "2":
                    payType = "2";
                    // Upoint оноогоор зарцуулалт хийх
                    break;

                case "1":
                    payType = "1";
                    // Виртуал данснаас зарцуулалт хийх
                    break;

                case "0":
                    // Бэлэн төлөлтөөр зарцуулалт хийх
                    payType = "0";
                    break;

                default:
                    payType = "1";
                    break;
                }

                if (dbconn.idbCheck(out dbres))
                {
                    string userCardNo  = string.Empty;
                    string userAdminNo = string.Empty;
                    if (dbconn.checkToken(token, out userCardNo, out userAdminNo))
                    {
                        if (checkCustomType(userCardNo))
                        {
                            localConvertProdcutMdl convProd = new localConvertProdcutMdl();
                            convProd.BranchId       = "286";
                            convProd.Channel        = "6";
                            convProd.cardNo         = userCardNo;
                            convProd.ConvertProduct = toProductId;
                            convProd.Pay_type       = payType;
                            convProd.Username       = userAdminNo;
                            string convJson      = serializer.Serialize(convProd);
                            string localResponse = string.Empty;
                            if (httpUtil.httpCall_POST_local(convJson, "processProduct", out localResponse))
                            {
                                LogWriter._upgradeProduct(TAG, string.Format("Local Service Response: [{0}]", localResponse));
                                var convObj = serializer.Deserialize <localCheckProductResponse>(localResponse);
                                if (convObj.issuccess)
                                {
                                    response.isSuccess     = true;
                                    response.resultCode    = HttpStatusCode.OK.ToString();
                                    response.resultMessage = convObj.errorMsg;
                                }
                                else
                                {
                                    response.isSuccess     = false;
                                    response.resultCode    = HttpStatusCode.NotFound.ToString();
                                    response.resultMessage = convObj.errorMsg;
                                }
                            }
                            else
                            {
                                response.isSuccess     = false;
                                response.resultCode    = HttpStatusCode.NotFound.ToString();
                                response.resultMessage = "Дотоод сервис дуудахад алдаа гарлаа.";
                            }
                        }
                        else
                        {
                            response.isSuccess     = false;
                            response.resultCode    = HttpStatusCode.NotFound.ToString();
                            response.resultMessage = "Дараа төлбөрт хэрэглэгч багц ахиулах боломжгүй.";
                        }
                    }
                    else
                    {
                        response.isSuccess     = false;
                        response.resultCode    = HttpStatusCode.Unauthorized.ToString();
                        response.resultMessage = appConstantValues.MSG_EXPIRED;
                    }
                }
                else
                {
                    response.isSuccess     = false;
                    response.resultCode    = HttpStatusCode.NotFound.ToString();
                    response.resultMessage = appConstantValues.MSG_INTERNAL_ERROR;
                    LogWriter._error(TAG, dbres);
                }
            }
            catch (Exception ex)
            {
                response.isSuccess     = false;
                response.resultCode    = HttpStatusCode.NotFound.ToString();
                response.resultMessage = ex.Message;
                exceptionManager.ManageException(ex, TAG);
            }
            message = Request.CreateResponse(HttpStatusCode.OK, response);
            LogWriter._upgradeProduct(TAG, string.Format("[<<] IP: [{0}], Response: [{1}], Token: [{2}]", httpUtil.GetClientIPAddress(HttpContext.Current.Request), serializer.Serialize(response), token));
            return(message);
        }
        public HttpResponseMessage Post([FromBody] req_newPromotionRegisterModel injson)
        {
            HttpResponseMessage message = null;
            string token = HttpContext.Current.Request.Headers["Authorization"].Replace("Bearer ", "").Trim();

            defaultResponseModel response = new defaultResponseModel();

            try
            {
                // new promo--- this is ok

                LogWriter._promo(TAG, string.Format("[>>] Request: [{0}]", serializer.Serialize(injson)));
                if (token == "YGHM9SHBC81LMR4G")
                {
                    if (injson != null)
                    {
                        if (dbconn.idbCheck(out dbres))
                        {
                            string promoName = injson.promoName;
                            string promoText = injson.promoText;
                            string poster    = injson.promoPosterImageUrl;
                            string expire    = injson.expireDate;
                            int    promoId   = 0;
                            if (dbconn.iDBCommandRetID(chatbotQry._addNewPromo(promoName, promoText, poster, expire), out promoId))
                            {
                                string detRes = string.Empty;
                                foreach (var item in injson.detialImageUrls)
                                {
                                    if (promoId != 0)
                                    {
                                        string dbresult = dbconn.iDBCommand(chatbotQry._addNewPromoDetial(promoId.ToString(), item.detialImageUrls));
                                        LogWriter._promo(TAG, string.Format("Promo Id: [{0}], ImgUrl: [{1}], Result: [{2}]", promoId, item.detialImageUrls, dbresult));
                                    }
                                }
                                response.isSuccess     = true;
                                response.resultCode    = HttpStatusCode.OK.ToString();
                                response.resultMessage = "success";
                            }
                            else
                            {
                                response.isSuccess     = false;
                                response.resultCode    = HttpStatusCode.NotFound.ToString();
                                response.resultMessage = appConstantValues.MSG_INTERNAL_ERROR;
                            }
                        }
                        else
                        {
                            response.isSuccess     = false;
                            response.resultCode    = HttpStatusCode.NotFound.ToString();
                            response.resultMessage = appConstantValues.MSG_INTERNAL_ERROR;
                            LogWriter._error(TAG, dbres);
                        }
                    }
                    else
                    {
                        response.isSuccess     = false;
                        response.resultCode    = HttpStatusCode.NotFound.ToString();
                        response.resultMessage = "Хоосон утга";
                    }
                }
                else
                {
                    response.isSuccess     = false;
                    response.resultCode    = HttpStatusCode.Unauthorized.ToString();
                    response.resultMessage = appConstantValues.MSG_EXPIRED;
                }
            }
            catch (Exception ex)
            {
                exceptionManager.ManageException(ex, TAG);
                response.isSuccess     = false;
                response.resultCode    = HttpStatusCode.NotFound.ToString();
                response.resultMessage = appConstantValues.MSG_INTERNAL_ERROR;
            }
            message = Request.CreateResponse(HttpStatusCode.OK, response);
            LogWriter._promo(TAG, string.Format("[<<] Ip: [{0}], Token: [{1}], Response: [{2}]", httpUtil.GetClientIPAddress(HttpContext.Current.Request), token, serializer.Serialize(response)));
            return(message);
        }
Esempio n. 15
0
        public async Task <HttpResponseMessage> Get(string sourceName, string invoiceId)
        {
            HttpResponseMessage  message  = new HttpResponseMessage();
            defaultResponseModel response = new defaultResponseModel();

            LogWriter._qPay(TAG, string.Format(@"[>>] Request: (InvId: {0}, SourceName:{1}), ", invoiceId, sourceName));
            string token = HttpContext.Current.Request.Headers["Authorization"].Replace("Bearer ", "").Trim();

            try
            {
                if (token == "YGHM9SHBC81LMR4G")
                {
                    if (dbconn.idbCheck(out dbres))
                    {
                        if (invoiceId.Length != 0)
                        {
                            DataTable dt = dbconn.getTable(appServiceQry.getQpayInvoice(invoiceId));
                            if (dt.Rows.Count != 0)
                            {
                                string invId = dt.Rows[0]["STATUS"].ToString();
                                if (invId == "C")
                                {
                                    response.isSuccess     = true;
                                    response.resultCode    = HttpStatusCode.OK.ToString();
                                    response.resultMessage = "success";
                                }
                                else
                                {
                                    response.isSuccess     = false;
                                    response.resultCode    = HttpStatusCode.NotFound.ToString();
                                    response.resultMessage = "transaction is failed";
                                }
                            }
                            else
                            {
                                response.isSuccess     = false;
                                response.resultCode    = HttpStatusCode.NotFound.ToString();
                                response.resultMessage = "no Invoice";
                            }
                        }
                        else
                        {
                            response.isSuccess     = false;
                            response.resultCode    = HttpStatusCode.NotFound.ToString();
                            response.resultMessage = "bad invoice_no";
                        }
                    }
                    else
                    {
                        response.isSuccess     = false;
                        response.resultCode    = HttpStatusCode.NotFound.ToString();
                        response.resultMessage = appConstantValues.MSG_INTERNAL_ERROR;
                        LogWriter._error(TAG, dbres);
                    }
                }
                else
                {
                    response.isSuccess     = false;
                    response.resultCode    = HttpStatusCode.Unauthorized.ToString();
                    response.resultMessage = appConstantValues.MSG_EXPIRED;
                }
            }
            catch (Exception ex)
            {
                response.isSuccess     = false;
                response.resultCode    = HttpStatusCode.NotFound.ToString();
                response.resultMessage = ex.Message;
                exceptionManager.ManageException(ex, TAG);
            }
            message = Request.CreateResponse(HttpStatusCode.OK, response);
            LogWriter._qPay(TAG, string.Format("[<<] IP: [{0}], Response: [{1}]", httpUtil.GetClientIPAddress(HttpContext.Current.Request), serializer.Serialize(response)));
            return(message);
        }
        public HttpResponseMessage Post([FromBody] pushNotiModel injson)
        {
            HttpResponseMessage message = null;
            string token = HttpContext.Current.Request.Headers["Authorization"].Replace("Bearer ", "").Trim();
            defaultResponseModel response = new defaultResponseModel();

            LogWriter._noti(TAG, string.Format(@"[>>] Request: [{0}]", serializer.Serialize(injson)));
            googleAPIRequest googleRequest  = new googleAPIRequest();
            Notification     googleNotif    = new Notification();
            string           googleResponse = string.Empty;
            string           card           = string.Empty;

            try
            {
                if (token == "YGHM9SHBC81LMR4G")
                {
                    if (dbconn.idbCheck(out dbres))
                    {
                        if (injson.to == "public")
                        {
                            googleRequest.to           = "/topics/ddish";
                            googleNotif.body           = injson.notification.body;
                            googleNotif.title          = injson.notification.title;
                            googleRequest.notification = googleNotif;
                            card = string.Empty;
                        }
                        else
                        {
                            googleRequest.to           = injson.to;
                            googleNotif.body           = injson.notification.body;
                            googleNotif.title          = injson.notification.title;
                            googleRequest.notification = googleNotif;
                            card = injson.cardNo;
                        }
                        if (saveData(injson.notification.title, injson.notification.body, injson.expireDate, card))
                        {
                            if (httpUtil.httpCall_POST_google(serializer.Serialize(googleRequest), out googleResponse))
                            {
                                response.isSuccess     = true;
                                response.resultCode    = HttpStatusCode.OK.ToString();
                                response.resultMessage = googleResponse;
                            }
                            else
                            {
                                response.isSuccess     = true;
                                response.resultCode    = HttpStatusCode.OK.ToString();
                                response.resultMessage = googleResponse;
                            }
                        }
                        else
                        {
                            response.isSuccess     = false;
                            response.resultCode    = HttpStatusCode.NotFound.ToString();
                            response.resultMessage = appConstantValues.MSG_INTERNAL_ERROR;
                        }
                    }
                    else
                    {
                        response.isSuccess     = false;
                        response.resultCode    = HttpStatusCode.NotFound.ToString();
                        response.resultMessage = appConstantValues.MSG_INTERNAL_ERROR;
                        LogWriter._error(TAG, dbres);
                    }
                }
                else
                {
                    response.isSuccess     = false;
                    response.resultCode    = HttpStatusCode.Unauthorized.ToString();
                    response.resultMessage = appConstantValues.MSG_EXPIRED;
                }
            }
            catch (Exception ex)
            {
                exceptionManager.ManageException(ex, TAG);
                response.isSuccess     = false;
                response.resultCode    = HttpStatusCode.NotFound.ToString();
                response.resultMessage = appConstantValues.MSG_INTERNAL_ERROR;
            }
            message = Request.CreateResponse(HttpStatusCode.OK, response);
            LogWriter._noti(TAG, string.Format(@"[<<] IP: [{0}], Response: [{1}], Token: [{2}]", httpUtil.GetClientIPAddress(HttpContext.Current.Request), serializer.Serialize(response), token));
            return(message);
        }
Esempio n. 17
0
        public async Task <HttpResponseMessage> Post([FromBody] appMerchantRequestModel requestObj)
        {
            HttpResponseMessage  message  = new HttpResponseMessage();
            defaultResponseModel response = new defaultResponseModel();

            LogWriter._merchant(TAG, string.Format(@"[>>] Request: [{0}]", serializer.Serialize(requestObj)));
            try
            {
                string token = HttpContext.Current.Request.Headers["Authorization"].Replace("Bearer ", "").Trim();
                if (requestObj != null)
                {
                    if (dbconn.idbCheck(out dbres))
                    {
                        string genInvoice = genInvoice = convertors.generateInvoiceNo("1");
                        string cType      = requestObj.requestType;
                        if (token == "YGHM9SHBC81LMR4G")
                        {
                            switch (cType)
                            {
                            case "1017":
                                // charge OthersAccount No Login
                                if (registerChargeOthersAccountNoLoginRequest(token, genInvoice, requestObj.cOAccountNoLogin))
                                {
                                    response.isSuccess     = true;
                                    response.resultCode    = HttpStatusCode.OK.ToString();
                                    response.resultMessage = genInvoice;
                                }
                                else
                                {
                                    response.isSuccess     = false;
                                    response.resultCode    = HttpStatusCode.InternalServerError.ToString();
                                    response.resultMessage = "can't register";
                                }
                                break;

                            default:
                                response.isSuccess     = false;
                                response.resultCode    = HttpStatusCode.NotAcceptable.ToString();
                                response.resultMessage = "invalid request type";
                                break;
                            }
                        }
                        else
                        {
                            string userCardNo  = string.Empty;
                            string userAdminNo = string.Empty;
                            if (dbconn.checkToken(token, out userCardNo, out userAdminNo))
                            {
                                switch (cType)
                                {
                                case "1001":
                                    // charge Product
                                    if (registerChargeProductRequest(userCardNo, userAdminNo, token, genInvoice, requestObj.cProduct))
                                    {
                                        response.isSuccess     = true;
                                        response.resultCode    = HttpStatusCode.OK.ToString();
                                        response.resultMessage = genInvoice;
                                    }
                                    else
                                    {
                                        response.isSuccess     = false;
                                        response.resultCode    = HttpStatusCode.InternalServerError.ToString();
                                        response.resultMessage = "can't register";
                                    }
                                    break;

                                case "1004":
                                    // order Nvod
                                    if (registerOrderNvodRequest(userCardNo, userAdminNo, token, genInvoice, requestObj.cNvod))
                                    {
                                        response.isSuccess     = true;
                                        response.resultCode    = HttpStatusCode.OK.ToString();
                                        response.resultMessage = genInvoice;
                                    }
                                    else
                                    {
                                        response.isSuccess     = false;
                                        response.resultCode    = HttpStatusCode.InternalServerError.ToString();
                                        response.resultMessage = "can't register";
                                    }
                                    break;

                                case "1007":
                                    // charge Account
                                    if (registerChargeAccountRequest(userCardNo, userAdminNo, token, genInvoice, requestObj.cAccount))
                                    {
                                        response.isSuccess     = true;
                                        response.resultCode    = HttpStatusCode.OK.ToString();
                                        response.resultMessage = genInvoice;
                                    }
                                    else
                                    {
                                        response.isSuccess     = false;
                                        response.resultCode    = HttpStatusCode.InternalServerError.ToString();
                                        response.resultMessage = "can't register";
                                    }
                                    break;

                                case "1010":
                                    // charge OthersAccount
                                    if (registerChargeOthersAccountRequest(userAdminNo, token, genInvoice, requestObj.cOAccount))
                                    {
                                        response.isSuccess     = true;
                                        response.resultCode    = HttpStatusCode.OK.ToString();
                                        response.resultMessage = genInvoice;
                                    }
                                    else
                                    {
                                        response.isSuccess     = false;
                                        response.resultCode    = HttpStatusCode.InternalServerError.ToString();
                                        response.resultMessage = "can't register";
                                    }
                                    break;

                                case "1013":
                                    // upgrade Product
                                    if (registerUpgradeProductRequest(userCardNo, userAdminNo, token, genInvoice, requestObj.uProduct))
                                    {
                                        response.isSuccess     = true;
                                        response.resultCode    = HttpStatusCode.OK.ToString();
                                        response.resultMessage = genInvoice;
                                    }
                                    else
                                    {
                                        response.isSuccess     = false;
                                        response.resultCode    = HttpStatusCode.InternalServerError.ToString();
                                        response.resultMessage = "can't register";
                                    }
                                    break;

                                default:
                                    response.isSuccess     = false;
                                    response.resultCode    = HttpStatusCode.NotAcceptable.ToString();
                                    response.resultMessage = "invalid request type";
                                    break;
                                }
                            }
                            else
                            {
                                response.isSuccess     = false;
                                response.resultCode    = HttpStatusCode.Unauthorized.ToString();
                                response.resultMessage = appConstantValues.MSG_EXPIRED;
                            }
                        }
                    }
                    else
                    {
                        response.isSuccess     = false;
                        response.resultCode    = HttpStatusCode.NotFound.ToString();
                        response.resultMessage = dbres;
                        LogWriter._error(TAG, dbres);
                    }
                }
                else
                {
                    response.isSuccess     = false;
                    response.resultCode    = HttpStatusCode.NotFound.ToString();
                    response.resultMessage = "invalid request";
                }
            }
            catch (Exception ex)
            {
                response.isSuccess     = false;
                response.resultCode    = HttpStatusCode.NotFound.ToString();
                response.resultMessage = ex.Message;
                exceptionManager.ManageException(ex, TAG);
            }
            message = Request.CreateResponse(HttpStatusCode.OK, response);
            LogWriter._merchant(TAG, string.Format("[<<] IP: [{0}], Response: [{1}]", httpUtil.GetClientIPAddress(HttpContext.Current.Request), serializer.Serialize(response)));
            return(message);
        }
Esempio n. 18
0
        public HttpResponseMessage Get(string contentId)
        {
            HttpResponseMessage message = null;
            string token = HttpContext.Current.Request.Headers["Authorization"].Replace("Bearer ", "").Trim();
            defaultResponseModel response = new defaultResponseModel();

            try
            {
                if (dbconn.idbCheck(out dbres))
                {
                    string userCardNo  = string.Empty;
                    string userAdminNo = string.Empty;
                    if (dbconn.checkToken(token, out userCardNo, out userAdminNo))
                    {
                        // TODO. Энд кино захиалах код бичигдэнэ.

                        string beginDate = DateTime.Now.ToString(appConstantValues.FORMAT_DATE_TIME_LONG);
                        string endDate   = DateTime.Now.AddDays(3).ToString(appConstantValues.FORMAT_DATE_TIME_LONG);
                        string resMon    = string.Empty;
                        string resEng    = string.Empty;
                        string resCry    = string.Empty;
                        if (checkCustomType(userCardNo))
                        {
                            if (dbconn.callARProcedure(userCardNo, contentId, beginDate, endDate, "0", userAdminNo, out resEng, out resMon, out resCry))
                            {
                                response.isSuccess     = true;
                                response.resultCode    = HttpStatusCode.OK.ToString();
                                response.resultMessage = resMon;
                            }
                            else
                            {
                                response.isSuccess     = false;
                                response.resultCode    = HttpStatusCode.NotFound.ToString();
                                response.resultMessage = resMon;
                            }
                        }
                        else
                        {
                            response.isSuccess     = false;
                            response.resultCode    = HttpStatusCode.NotFound.ToString();
                            response.resultMessage = "Дараа төлбөрт хэрэглэгч захиалга хийх боломжгүй.";
                        }
                    }
                    else
                    {
                        response.isSuccess     = false;
                        response.resultCode    = HttpStatusCode.Unauthorized.ToString();
                        response.resultMessage = appConstantValues.MSG_EXPIRED;
                    }
                }
                else
                {
                    response.isSuccess     = false;
                    response.resultCode    = HttpStatusCode.NotFound.ToString();
                    response.resultMessage = appConstantValues.MSG_INTERNAL_ERROR;
                    LogWriter._error(TAG, dbres);
                }
            }
            catch (Exception ex)
            {
                exceptionManager.ManageException(ex, TAG);
                response.isSuccess     = false;
                response.resultCode    = HttpStatusCode.NotFound.ToString();
                response.resultMessage = appConstantValues.MSG_INTERNAL_ERROR;
            }
            message = Request.CreateResponse(HttpStatusCode.OK, response);
            LogWriter._pushVod(TAG, string.Format("IP: [{0}], Request: [{1}], Response: [{2}], Token: [{3}]", httpUtil.GetClientIPAddress(HttpContext.Current.Request), contentId, serializer.Serialize(response), token));
            return(message);
        }