Beispiel #1
0
 public ResponseModel ResponseWithUnAuthorize(string _errorMessage = "Unauthorized")
 {
     _response._data         = new DataTable();
     _response._statusCode   = _response.GetStateHttp(ResponseModel.StatusHttp.SecurityError);
     _response._errorMessage = _errorMessage;
     return(_response);
 }
Beispiel #2
0
        public IActionResult installmentTable([FromBody] RequestModel request)
        {
            ResponseModel      result = new ResponseModel();
            List <TempReceipt> dt     = new List <TempReceipt>();

            try
            {
                result._data         = customer.REST_InstallmentTable(request.data.AgreementNo);
                result._errorMessage = "";
                dt = result._data.AsEnumerable().Select(t => new TempReceipt()
                {
                    AgreementNo = t.Field <string>("Contno"),
                    ReceiptUrl  = t.Field <string>("ReceiptUrl"),
                    Period      = t.Field <int>("Period")
                }).ToList();

                for (int i = 0; i < dt.Count; i++)
                {
                    if (!string.IsNullOrEmpty(dt[i].ReceiptUrl))
                    {
                        result._data.Rows[i]["ReceiptUrl"] = AESEncrypt.AESOperation.EncryptString(string.Format("{0}/{1}.pdf", state.ResourceUrl.documentsUrl, dt[i].ReceiptUrl));
                    }
                    else
                    {
                        result._data.Rows[i]["ReceiptUrl"] = dt[i].ReceiptUrl;
                    }
                    Console.WriteLine("Normal : " + string.Format("{0}/{1}.pdf", state.ResourceUrl.documentsUrl, dt[i].ReceiptUrl));
                    Console.WriteLine("----------------------------------");
                    Console.WriteLine("Encrypt : " + AESEncrypt.AESOperation.EncryptString(string.Format("{0}.pdf", dt[i].ReceiptUrl)));
                    Console.WriteLine("----------------------------------");
                    Console.WriteLine("Decrypt : " + AESEncrypt.AESOperation.DecryptString(AESEncrypt.AESOperation.EncryptString(string.Format("{0}.pdf", dt[i].ReceiptUrl))));
                    Console.WriteLine("----------------------------------");
                }

                if (result._data.Rows.Count == 0)
                {
                    result._statusCode = result.GetStateHttp(ResponseModel.StatusHttp.NotFound);
                    return(NotFound(result));
                }
                result._statusCode = result.GetStateHttp(ResponseModel.StatusHttp.OK);
                return(Ok(result));
            }
            catch (Exception e)
            {
                result._data         = new DataTable();
                result._statusCode   = result.GetStateHttp(ResponseModel.StatusHttp.InternalError);
                result._errorMessage = e.Message;
                return(BadRequest(result));
            }
        }
        public ResponseModel SerializeObject(DataTable _data, StatusHttp _statusCode, string _errorMessage)
        {
            _response._data         = _data;
            _response._statusCode   = _response.GetStateHttp(_statusCode);
            _response._errorMessage = _errorMessage;

            return(_response);
        }
Beispiel #4
0
        public IActionResult purchaseHistory([FromBody] RequestModel request)
        {
            ResponseModel result = new ResponseModel();

            try
            {
                result._data         = customer.REST_PurchaseHistory(request.data.Id);
                result._errorMessage = "";
                if (result._data.Rows.Count == 0)
                {
                    result._statusCode = result.GetStateHttp(ResponseModel.StatusHttp.NotFound);
                    return(NotFound(result));
                }
                result._statusCode = result.GetStateHttp(ResponseModel.StatusHttp.OK);
                return(Ok(result));
            }
            catch (Exception e)
            {
                result._data         = new DataTable();
                result._statusCode   = result.GetStateHttp(ResponseModel.StatusHttp.InternalError);
                result._errorMessage = e.Message;
                return(BadRequest(result));
            }
        }