Пример #1
0
        public HttpResponseMessage AddCashInIso20022(HttpRequestMessage reqObject)
        {
            string result        = string.Empty;
            int    result_result = 0;
            string result_msg    = "information hasn't been added";
            var    requestedData = reqObject.Content.ReadAsStringAsync().Result;

            mTaka.Utility.ISO20022.Pacs008.Document obj = new mTaka.Utility.ISO20022.Pacs008.Document();
            Exception ex;
            var       deserializestatus = Utility.ISO20022.Pacs008.Document.Deserialize(requestedData, out obj, out ex);

            if (!deserializestatus)
            {
                return(new HttpResponseMessage(HttpStatusCode.NotAcceptable));
            }
            var responseDoucment = new mTaka.Utility.ISO20022.Camt054.Document();

            var cdtTrxInf = obj?.FIToFICstmrCdtTrf.CdtTrfTxInf.FirstOrDefault();

            if (cdtTrxInf?.IntrBkSttlmAmt.Value != null)
            {
                var creditorAccount = cdtTrxInf?.CdtrAcct.Id.Item as GenericAccountIdentification1;
                var debitorAccount  = cdtTrxInf?.DbtrAcct.Id.Item as GenericAccountIdentification1;
                _UserTransaction = new UserTransaction()
                {
                    FromSystemAccountNo = debitorAccount?.Id,
                    ToSystemAccountNo   = creditorAccount?.Id,
                    DefineServiceId     = "003",
                    FunctionId          = "090107003",
                    FunctionName        = "CashIn",
                    Amount    = (decimal)cdtTrxInf?.IntrBkSttlmAmt.Value,
                    Narration = "Cashout",
                    MakeBy    = "Prova"
                };

                bool IsValid = ModelValidation.TryValidateModel(_UserTransaction, out _modelErrorMsg);
                if (IsValid)
                {
                    result = _ICashInService.AddCashIn(_UserTransaction, out responseDoucment);
                    var split = result.ToString().Split(':');
                    result_result = Convert.ToInt32(split[0]);
                    result_msg    = split[1];
                }
            }
            if (result_result == 1)
            {
                var ntfctn = responseDoucment.BkToCstmrDbtCdtNtfctn.Ntfctn.FirstOrDefault() ?? new AccountNotification15();
                var ntry   = ntfctn.Ntry.FirstOrDefault() ?? new ReportEntry9();
                ntry.CdtDbtInd = CreditDebitCode.CRDT;
            }

            var responseString = responseDoucment.Serialize(new UTF8Encoding());

            return(_IDataManipulation.CreateHttpResponseXml(responseString));

            if (!string.IsNullOrWhiteSpace(_modelErrorMsg))
            {
                _serviceResponse = _IDataManipulation.SetResponseObject(result_result, _modelErrorMsg);
            }
            else
            {
                _serviceResponse = _IDataManipulation.SetResponseObject(result_result, result_msg);
            }
            _response = _IDataManipulation.CreateResponse(_serviceResponse, reqObject);
            return(_response);
        }