public HttpResponseMessage GetTransactionRuleById(HttpRequestMessage requestObj)
        {
            string TransactionRuleId = string.Empty;

            _requestedDataObject = _IDataManipulation.GetRequestedDataObject(requestObj);
            if (_requestedDataObject != null && _requestedDataObject.BusinessData != null)
            {
                _TransactionRules = JsonConvert.DeserializeObject <TransactionRules>(_requestedDataObject.BusinessData);
                TransactionRuleId = _TransactionRules.TransactionRuleId;
            }

            if (!string.IsNullOrWhiteSpace(TransactionRuleId))
            {
                _TransactionRules = new TransactionRules();
                _TransactionRules = _ITransactionRulesService.GetAccountRuleById(TransactionRuleId);
            }
            if (_TransactionRules != null)
            {
                _serviceResponse = _IDataManipulation.ResopnseWhenDataFound(_TransactionRules, "Account Rule Found");
            }
            else
            {
                _serviceResponse = _IDataManipulation.ResopnseWhenDataNotFound("Account Rule Not Found");
            }
            _response = _IDataManipulation.CreateResponse(_serviceResponse, requestObj);
            return(_response);
        }
        public HttpResponseMessage DeleteTransactionRule(HttpRequestMessage requestObj)
        {
            int result = 0;

            _requestedDataObject = _IDataManipulation.GetRequestedDataObject(requestObj);

            if (_requestedDataObject != null && _requestedDataObject.BusinessData != null)
            {
                _TransactionRules = JsonConvert.DeserializeObject <TransactionRules>(_requestedDataObject.BusinessData);
            }
            if (_TransactionRules == null || string.IsNullOrWhiteSpace(_TransactionRules.TransactionRuleId))
            {
                _serviceResponse = _IDataManipulation.ResopnseWhenDataNotFound("Account Rule Not found");
                _response        = _IDataManipulation.CreateResponse(_serviceResponse, requestObj);
            }
            else
            {
                result = _ITransactionRulesService.DeleteTransactionRules(_TransactionRules);
            }
            if (result == 1)
            {
                _serviceResponse = _IDataManipulation.ResopnseWhenDataFound(result, "Account Rule Delete Successfully");
            }
            else
            {
                _serviceResponse = _IDataManipulation.ResopnseWhenDataNotFound("Account Rule Not Updated");
            }

            _response = _IDataManipulation.CreateResponse(_serviceResponse, requestObj);
            return(_response);
        }
Пример #3
0
        public static Amount FeeForSerializeSize(Amount feePerKb, int txSerializeSize)
        {
            if (feePerKb < 0)
            {
                throw Errors.RequireNonNegative(nameof(feePerKb));
            }
            if (txSerializeSize < 0)
            {
                throw Errors.RequireNonNegative(nameof(txSerializeSize));
            }

            var fee = feePerKb * txSerializeSize / 1000;

            if (fee == 0 && feePerKb > 0)
            {
                fee = feePerKb;
            }

            if (!TransactionRules.IsSaneOutputValue(fee))
            {
                throw new TransactionRuleException($"Fee of {fee} is invalid");
            }

            return(fee);
        }
        public HttpResponseMessage EditTransactionRule(HttpRequestMessage requestObj)
        {
            int result = 0;

            _requestedDataObject = _IDataManipulation.GetRequestedDataObject(requestObj);
            if (_requestedDataObject != null && _requestedDataObject.BusinessData != null)
            {
                _TransactionRules = JsonConvert.DeserializeObject <TransactionRules>(_requestedDataObject.BusinessData);
                bool IsValid = ModelValidation.TryValidateModel(_TransactionRules, out _modelErrorMsg);
                if (IsValid)
                {
                    result = _ITransactionRulesService.EditTransactionRules(_TransactionRules);
                }
            }

            if (!string.IsNullOrWhiteSpace(_modelErrorMsg))
            {
                _serviceResponse = _IDataManipulation.SetResponseObject(result, _modelErrorMsg);
            }
            else if (result == 1)
            {
                _serviceResponse = _IDataManipulation.SetResponseObject(result, "information has been updated successfully");
            }
            else
            {
                _serviceResponse = _IDataManipulation.SetResponseObject(result, "information hasn't been updated");
            }
            _response = _IDataManipulation.CreateResponse(_serviceResponse, requestObj);
            return(_response);
        }
        public int AddTransactionRules(TransactionRules _TransactionRules)
        {
            try
            {
                var _max = _IUoW.Repository <TransactionRules>().GetMaxValue(x => x.TransactionRuleId) + 1;
                _TransactionRules.TransactionRuleId = _max.ToString().PadLeft(3, '0');
                _TransactionRules.AuthStatusId      = "U";
                _TransactionRules.LastAction        = "ADD";
                _TransactionRules.MakeBy            = "prova";
                _TransactionRules.MakeDT            = System.DateTime.Now;

                #region Switch

                if (_TransactionRules.TranactionAllowed == "True")
                {
                    _TransactionRules.TranactionAllowed = "1";
                }
                else
                {
                    _TransactionRules.TranactionAllowed = "0";
                }
                if (_TransactionRules.commissionAllowed == "True")
                {
                    _TransactionRules.commissionAllowed = "1";
                }
                else
                {
                    _TransactionRules.commissionAllowed = "0";
                }
                #endregion

                _TransactionRules.MakeDT = System.DateTime.Now;
                var result = _IUoW.Repository <TransactionRules>().Add(_TransactionRules);
                #region Auth Log
                if (result == 1)
                {
                    _IAuthLogService = new AuthLogService();
                    long _outMaxSlAuthLogDtl = 0;
                    _IAuthLogService.AddAuthLog(_IUoW, null, _TransactionRules, "ADD", "0001", _TransactionRules.FunctionId, 1, "TransactionRules", "MTK_SP_TRANSACTION_RULES", "TransactionRuleId", _TransactionRules.TransactionRuleId, _TransactionRules.UserName, _outMaxSlAuthLogDtl, out _outMaxSlAuthLogDtl);
                }
                #endregion

                if (result == 1)
                {
                    _IUoW.Commit();
                }
                return(result);
            }
            catch (Exception ex)
            {
                _ObjErrorLogService = new ErrorLogService();
                _ObjErrorLogService.AddErrorLog(ex, string.Empty, "AddTransactionRules(obj)", string.Empty);
                return(0);
            }
        }
        public int DeleteTransactionRules(TransactionRules _TransactionRules)
        {
            try
            {
                int  result = 0;
                bool IsRecordExist;

                if (!string.IsNullOrWhiteSpace(_TransactionRules.TransactionRuleId))
                {
                    IsRecordExist = _IUoW.Repository <TransactionRules>().IsRecordExist(x => x.TransactionRuleId == _TransactionRules.TransactionRuleId);
                    if (IsRecordExist)
                    {
                        var _OldTransactionRule       = _IUoW.Repository <TransactionRules>().GetBy(x => x.TransactionRuleId == _TransactionRules.TransactionRuleId);
                        var _OldTransactionRuleForLog = ObjectCopier.DeepCopy(_OldTransactionRule);

                        _OldTransactionRule.AuthStatusId = "D";
                        _OldTransactionRule.LastUpdateDT = System.DateTime.Now;
                        _OldTransactionRule.LastAction   = "DEL";

                        result = _IUoW.Repository <TransactionRules>().Update(_OldTransactionRule);

                        #region Auth log
                        if (result == 1)
                        {
                            _IAuthLogService = new AuthLogService();
                            long _outMaxSlAuthLogDtl = 0;
                            _IAuthLogService.AddAuthLog(_IUoW, _OldTransactionRuleForLog, _TransactionRules, "DEL", "0001", _TransactionRules.FunctionId, 1, "TransactionRules", "MTK_SP_TRANSACTION_RULES", "TransactionRuleId", _TransactionRules.TransactionRuleId, _TransactionRules.UserName, _outMaxSlAuthLogDtl, out _outMaxSlAuthLogDtl);
                        }

                        #endregion

                        if (result == 1)
                        {
                            _IUoW.Commit();
                        }
                        return(result);
                    }
                }
                return(result);
            }
            catch (Exception ex)
            {
                _ObjErrorLogService = new ErrorLogService();
                _ObjErrorLogService.AddErrorLog(ex, string.Empty, "DeleteTransactionRules(obj)", string.Empty);
                return(0);
            }
        }
 public TransactionRules GetAccountRuleBy(TransactionRules _TransactionRules)
 {
     try
     {
         if (_TransactionRules == null)
         {
             return(_TransactionRules);
         }
         return(_IUoW.Repository <TransactionRules>().GetBy(x => x.TransactionRuleId == _TransactionRules.TransactionRuleId &&
                                                            x.AuthStatusId != "D" &&
                                                            x.LastAction != "DEL"));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 public HttpResponseMessage GetTransactionRuleBy(HttpRequestMessage requestObj)
 {
     _requestedDataObject = _IDataManipulation.GetRequestedDataObject(requestObj);
     if (_requestedDataObject != null && _requestedDataObject.BusinessData != null)
     {
         _TransactionRules = JsonConvert.DeserializeObject <TransactionRules>(_requestedDataObject.BusinessData);
         _TransactionRules = _ITransactionRulesService.GetAccountRuleBy(_TransactionRules);
     }
     if (_TransactionRules != null)
     {
         _serviceResponse = _IDataManipulation.ResopnseWhenDataFound(_TransactionRules, "Account Rule Fouingd");
     }
     else
     {
         _serviceResponse = _IDataManipulation.ResopnseWhenDataNotFound("Account Rule Not Found");
     }
     _response = _IDataManipulation.CreateResponse(_serviceResponse, requestObj);
     return(_response);
 }
Пример #9
0
        /// <summary>
        /// Potentially adds a change output to a transaction to set an appropiate fee.
        /// </summary>
        public static Transaction AddChange(Transaction tx, Amount totalInput, OutputScript changeScript, Amount feePerKb)
        {
            if (tx == null)
            {
                throw new ArgumentNullException(nameof(tx));
            }
            if (totalInput < 0)
            {
                throw Errors.RequireNonNegative(nameof(totalInput));
            }
            if (changeScript == null)
            {
                throw new ArgumentNullException(nameof(changeScript));
            }
            if (feePerKb < 0)
            {
                throw Errors.RequireNonNegative(nameof(feePerKb));
            }

            var txSerializeSizeEstimate = Transaction.EstimateSerializeSize(tx.Inputs.Length, tx.Outputs, true);
            var feeEstimate             = FeeForSerializeSize(feePerKb, txSerializeSizeEstimate);

            var totalNonChangeOutput = tx.Outputs.Sum(o => o.Amount);
            var changeAmount         = totalInput - totalNonChangeOutput - feeEstimate;
            var changeOutput         = new Transaction.Output(changeAmount, Transaction.SupportedVersion, changeScript.Script);

            // Change should not be created if the change output itself would be considered dust.
            if (TransactionRules.IsDust(changeOutput, feePerKb))
            {
                return(tx);
            }

            var outputList = tx.Outputs.ToList();

            outputList.Add(changeOutput); // TODO: Randomize change output position.
            var outputs = outputList.ToArray();

            return(new Transaction(tx.Version, tx.Inputs, outputs, tx.LockTime, tx.Expiry));
        }
        public HttpResponseMessage AddTransactionRule(HttpRequestMessage requestObj)
        {
            int result = 0;

            _requestedDataObject = _IDataManipulation.GetRequestedDataObject(requestObj);
            if (_requestedDataObject != null && _requestedDataObject.BusinessData != null)
            {
                _TransactionRules = JsonConvert.DeserializeObject <TransactionRules>(_requestedDataObject.BusinessData);
                result            = _ITransactionRulesService.AddTransactionRules(_TransactionRules);
            }
            if (result == 1)
            {
                _serviceResponse = _IDataManipulation.SetResponseObject(result, "information has been added successfully");
            }
            else
            {
                _serviceResponse = _IDataManipulation.SetResponseObject(result, "information can't be added successfully");
            }

            _response = _IDataManipulation.CreateResponse(_serviceResponse, requestObj);
            return(_response);
        }
Пример #11
0
        public override ValidationResult Validate(object value, CultureInfo cultureInfo)
        {
            try
            {
                double doubleResult;
                if (!double.TryParse((string)value, out doubleResult))
                {
                    return(new ValidationResult(false, "String to double conversion failed"));
                }

                var amount = Denomination.Decred.AmountFromDouble(doubleResult);

                if (!AllowNegative && amount < 0)
                {
                    return(new ValidationResult(false, "Value must be non-negative"));
                }

                if (RestrictProducable)
                {
                    var positiveAmount = amount;
                    if (positiveAmount < 0)
                    {
                        positiveAmount = -amount;
                    }
                    if (!TransactionRules.IsSaneOutputValue(positiveAmount))
                    {
                        return(new ValidationResult(false, "Value exceeds allowed bounds"));
                    }
                }

                return(new ValidationResult(true, null));
            }
            catch (Exception e)
            {
                return(new ValidationResult(false, e));
            }
        }
Пример #12
0
        public string AddCashIn(UserTransaction _UserTransaction, out mTaka.Utility.ISO20022.Camt054.Document document)
        {
            document = new Document();
            var grpHdr = document.BkToCstmrDbtCdtNtfctn.GrpHdr;

            grpHdr.MsgId   = mTaka.Utility.ISO.ISOHelper.RandomString();
            grpHdr.CreDtTm = DateTime.Now;
            var ntfctn = document.BkToCstmrDbtCdtNtfctn.Ntfctn.FirstOrDefault();
            var ntry   = ntfctn?.Ntry.FirstOrDefault();

            if (ntry != null)
            {
                ntry.Amt = new ActiveOrHistoricCurrencyAndAmount()
                {
                    Ccy = "BDT", Value = _UserTransaction.Amount
                };
                ntry.CdtDbtInd = CreditDebitCode.DBIT;
                ntry.Sts       = new EntryStatus1Choice()
                {
                    Item = "Other", ItemElementName = ItemChoiceType9.Prtry
                };
            }

            grpHdr.MsgPgntn.LastPgInd = true;
            grpHdr.MsgPgntn.PgNb      = "1";
            int result = 0;

            _UserTransaction.TransDT = Convert.ToDateTime(System.DateTime.Now.ToString("dd/MM/yyyy"));
            string           split_result    = string.Empty;
            string           MainAuthFlag    = string.Empty;
            AccMasterService _AccInfoService = new AccMasterService();
            AccMaster        _AccInfo_Post   = new AccMaster();
            AccMaster        _AccInfo_Get    = new AccMaster();

            StatusWiseServiceService _StatusWiseServiceService = new StatusWiseServiceService();
            StatusWiseService        _StatusWiseService        = new StatusWiseService();
            int CheckStatusWiseService = 0;

            TransactionRulesService _TransactionRulesService = new TransactionRulesService();
            TransactionRules        _TransactionRules        = new TransactionRules();
            int CheckTransactionRules = 0;

            AccLimitSetupService _AccLimitSetupService = new AccLimitSetupService();
            AccLimitSetup        _AccLimitSetup        = new AccLimitSetup();
            string CheckAccLimit = string.Empty;

            try
            {
                #region Get SystemAccountNo by WalletAccountNo
                _AccInfo_Post.FromSystemAccountNo = _UserTransaction.FromSystemAccountNo;
                _AccInfo_Post.ToSystemAccountNo   = _UserTransaction.ToSystemAccountNo;
                _AccInfo_Post.FunctionId          = _UserTransaction.FunctionId;
                _AccInfo_Get = _AccInfoService.GetAccInfo(_AccInfo_Post);
                if (_AccInfo_Get == null || _AccInfo_Get.FromSystemAccountNo == null || _AccInfo_Get.ToSystemAccountNo == null)
                {
                    split_result    = result + ":" + "Account No. not valid..";
                    grpHdr.AddtlInf = "Account No. not valid..";


                    return(split_result);
                }
                #endregion

                #region Check StatusWiseService
                _StatusWiseService.ToSystemAccountNo = _AccInfo_Get.ToSystemAccountNo;
                _StatusWiseService.DefineServiceId   = _UserTransaction.DefineServiceId;
                CheckStatusWiseService = _StatusWiseServiceService.CheckStatusWiseService(_StatusWiseService);
                if (CheckStatusWiseService == 0)
                {
                    split_result    = result + ":" + "Account No. is not active for this transaction..";
                    grpHdr.AddtlInf = "Account No. is not active for this transaction..";
                    return(split_result);
                }
                #endregion

                #region Check TransactionRules
                _TransactionRules.FromSystemAccountNo = _AccInfo_Get.FromSystemAccountNo;
                _TransactionRules.ToSystemAccountNo   = _AccInfo_Get.ToSystemAccountNo;
                _TransactionRules.DefineServiceId     = _UserTransaction.DefineServiceId;
                CheckTransactionRules = _TransactionRulesService.CheckTransactionRules(_TransactionRules);
                if (CheckTransactionRules == 0)
                {
                    split_result    = result + ":" + "Transaction is not allowed..";
                    grpHdr.AddtlInf = "Transaction is not allowed..";
                    return(split_result);
                }
                #endregion

                #region Check Limit
                _AccLimitSetup.FromSystemAccountNo = _AccInfo_Get.FromSystemAccountNo;
                _AccLimitSetup.FromAccType         = _AccInfo_Get.FromAccType;
                _AccLimitSetup.ToSystemAccountNo   = _AccInfo_Get.ToSystemAccountNo;
                _AccLimitSetup.ToAccType           = _AccInfo_Get.ToAccType;
                _AccLimitSetup.DefineServiceId     = _UserTransaction.DefineServiceId;
                _AccLimitSetup.Amount  = _UserTransaction.Amount;
                _AccLimitSetup.TransDT = _UserTransaction.TransDT;
                CheckAccLimit          = _AccLimitSetupService.CheckAccLimit(_AccLimitSetup);
                if (CheckAccLimit != "true")
                {
                    split_result = result + ":" + CheckAccLimit;
                    return(split_result);
                }
                #endregion

                if (_AccInfo_Get.FromSystemAccountNo != null && _AccInfo_Get.ToSystemAccountNo != null && CheckStatusWiseService != 0 && CheckTransactionRules != 0 && CheckAccLimit == "true")
                {
                    var _max = _IUoW.Repository <UserTransaction>().GetMaxValue(x => x.SerialId) + 1;
                    _UserTransaction.SerialId            = _max.ToString().PadLeft(3, '0');
                    _UserTransaction.AuthStatusId        = "U";
                    _UserTransaction.LastAction          = "ADD";
                    _UserTransaction.MakeDT              = System.DateTime.Now;
                    _UserTransaction.MakeBy              = "prova";
                    _UserTransaction.FromSystemAccountNo = _AccInfo_Get.FromSystemAccountNo;
                    _UserTransaction.ToSystemAccountNo   = _AccInfo_Get.ToSystemAccountNo;
                    result = _IUoW.Repository <UserTransaction>().Add(_UserTransaction);

                    #region Auth Log
                    if (result == 1)
                    {
                        string url = ConfigurationManager.AppSettings["LgurdaService_server"] + "/GetAuthPermissionByFunctionId/" + _UserTransaction.FunctionId + "/" + _UserTransaction.FunctionName + "?format=json";
                        using (WebClient wc = new WebClient())
                        {
                            TransactionRules OBJ_TransactionRules = new TransactionRules();
                            var json = wc.DownloadString(url);
                            OBJ_TransactionRules = JsonConvert.DeserializeObject <TransactionRules>(json);
                            MainAuthFlag         = OBJ_TransactionRules.GetAuthPermissionByFunctionIdResult;
                        }
                        if (MainAuthFlag == "1")
                        {
                            _IAuthLogService = new AuthLogService();
                            long _outMaxSlAuthLogDtl = 0;
                            result = _IAuthLogService.AddAuthLog(_IUoW, null, _UserTransaction, "ADD", "0001", _UserTransaction.FunctionId, 1, "CashIn", "MTK_USER_TXN", "SerialId", _UserTransaction.SerialId, "prova", _outMaxSlAuthLogDtl, out _outMaxSlAuthLogDtl);
                        }
                        if (MainAuthFlag == "0")
                        {
                            _IAuthLogService = new AuthLogService();
                            FTAuthLog _ObjAuthLog = new FTAuthLog();
                            _ObjAuthLog.TableNm       = "MTK_USER_TXN";
                            _ObjAuthLog.AuthStatusId  = "A";
                            _ObjAuthLog.LastAction    = "ADD";
                            _ObjAuthLog.FunctionId    = _UserTransaction.FunctionId;
                            _ObjAuthLog.TablePkColVal = _UserTransaction.SerialId;
                            result = _IAuthLogService.SetTableObject_FT <UserTransaction>(_IUoW, _ObjAuthLog, _UserTransaction);
                        }
                    }
                    #endregion

                    if (result == 1)
                    {
                        _IUoW.Commit();

                        split_result    = result + ":" + "Saved Successfully";
                        grpHdr.AddtlInf = "Saved Successfully";
                    }
                    else
                    {
                        split_result    = result + ":" + "information hasn't been added";
                        grpHdr.AddtlInf = "information hasn't been added";
                    }
                }
            }
            catch (Exception ex)
            {
                _ObjErrorLogService = new ErrorLogService();
                _ObjErrorLogService.AddErrorLog(ex, string.Empty, "AddCashIn(obj)", string.Empty);
                split_result    = result + ":" + "";
                grpHdr.AddtlInf = "";
            }
            return(split_result);
        }
Пример #13
0
        /// <summary>
        /// Builds a transaction that sends value from one address to another.
        /// Change is spent to the source address, if necessary.
        /// </summary>
        /// <param name="request"></param>
        /// <param name="feeFactor"></param>
        /// <returns></returns>
        /// <exception cref="BusinessException"></exception>
        public async Task <BuildTransactionResponse> BuildSingleTransactionAsync(BuildSingleTransactionRequest request, decimal feeFactor)
        {
            if (string.IsNullOrWhiteSpace(request.FromAddress))
            {
                throw new BusinessException(ErrorReason.BadRequest, "FromAddress missing");
            }
            if (string.IsNullOrWhiteSpace(request.ToAddress))
            {
                throw new BusinessException(ErrorReason.BadRequest, "ToAddress missing");
            }
            if (!long.TryParse(request.Amount, out var amount) || amount <= 0)
            {
                throw new BusinessException(ErrorReason.BadRequest, $"Invalid amount {amount}");
            }

            var feePerKb = await _feeService.GetFeePerKb();

            if (TransactionRules.IsDustAmount(amount, Transaction.PayToPubKeyHashPkScriptSize, new Amount(feePerKb)))
            {
                throw new BusinessException(ErrorReason.AmountTooSmall, "Amount is dust");
            }

            const int outputVersion = 0;
            const int lockTime      = 0;
            const int expiry        = 0;

            // Number of outputs newly build tx will contain,
            // not including the change address
            const int numOutputs = 1;

            // Lykke api doesn't have option to specify a change address.
            var changeAddress = Address.Decode(request.FromAddress);
            var toAddress     = Address.Decode(request.ToAddress);
            var allInputs     = (await GetUtxosForAddress(request.FromAddress)).ToList();

            long estFee         = 0;
            long totalSpent     = 0;
            var  consumedInputs = new List <Transaction.Input>();

            bool HasEnoughInputs(out long fee)
            {
                var calculateWithChange = false;

                while (true)
                {
                    var changeCount = calculateWithChange ? 1 : 0;
                    fee = _feeService.CalculateFee(feePerKb, consumedInputs.Count, numOutputs + changeCount, feeFactor);
                    var estAmount = amount + (request.IncludeFee ? 0 : fee);

                    if (totalSpent < estAmount)
                    {
                        return(false);
                    }
                    if (totalSpent == estAmount)
                    {
                        return(true);
                    }
                    if (totalSpent > estAmount && calculateWithChange)
                    {
                        return(true);
                    }

                    // Loop one more time but make sure change is accounted for this time.
                    if (totalSpent > estAmount)
                    {
                        calculateWithChange = true;
                    }
                }
            }

            // Accumulate inputs until we have enough to cover the cost
            // of the amount + fee
            foreach (var input in allInputs)
            {
                // Don't consume an outpoint if it's spent.
                if (await IsBroadcastedUtxo(input.PreviousOutpoint))
                {
                    continue;
                }

                consumedInputs.Add(input);
                totalSpent += input.InputAmount;

                if (HasEnoughInputs(out estFee))
                {
                    break;
                }
            }

            // If all inputs do not have enough value to fund the transaction.
            if (totalSpent < amount + (request.IncludeFee ? 0 : estFee))
            {
                throw new BusinessException(ErrorReason.NotEnoughBalance, "Address balance too low");
            }

            // The fee either comes from the change or the sent amount
            var send   = amount - (request.IncludeFee ? estFee : 0);
            var change = (totalSpent - amount) - (request.IncludeFee ? 0 : estFee);

            // If all inputs do not have enough value to fund the transaction, throw error.
            if (request.IncludeFee && estFee > amount)
            {
                throw new BusinessException(ErrorReason.AmountTooSmall, "Amount not enough to include fee");
            }

            // If all inputs do not have enough value to fund the transaction, throw error.
            if (totalSpent < amount + (request.IncludeFee ? 0 : estFee))
            {
                throw new BusinessException(ErrorReason.NotEnoughBalance, "Address balance too low");
            }

            // Build outputs to address + change address.
            // If any of the outputs is zero value, exclude it.  For example, if there is no change.
            var outputs = new[] {
                new Transaction.Output(send, outputVersion, toAddress.BuildScript().Script),
                new Transaction.Output(change, outputVersion, changeAddress.BuildScript().Script)
            }.Where(o => o.Amount != 0).ToArray();

            var newTx = new Transaction(
                Transaction.SupportedVersion,
                consumedInputs.ToArray(),
                outputs,
                lockTime,
                expiry
                );

            return(new BuildTransactionResponse
            {
                TransactionContext = HexUtil.FromByteArray(newTx.Serialize())
            });
        }
Пример #14
0
        /// <summary>
        /// Constructs an unsigned transaction by referencing previous unspent outputs.
        /// A change output is added when necessary to return extra value back to the wallet.
        /// </summary>
        /// <param name="outputs">Transaction output array without change.</param>
        /// <param name="changeScript">Output script to pay change to.</param>
        /// <param name="fetchInputsAsync">Input selection source.</param>
        /// <returns>Unsigned transaction and total input amount.</returns>
        /// <exception cref="InsufficientFundsException">Input source was unable to provide enough input value.</exception>
        public static async Task <Tuple <Transaction, Amount> > BuildUnsignedTransaction(Transaction.Output[] outputs,
                                                                                         Amount feePerKb,
                                                                                         InputSource fetchInputsAsync,
                                                                                         ChangeSource fetchChangeAsync)
        {
            if (outputs == null)
            {
                throw new ArgumentNullException(nameof(outputs));
            }
            if (fetchInputsAsync == null)
            {
                throw new ArgumentNullException(nameof(fetchInputsAsync));
            }
            if (fetchChangeAsync == null)
            {
                throw new ArgumentNullException(nameof(fetchChangeAsync));
            }

            var targetAmount  = outputs.Sum(o => o.Amount);
            var estimatedSize = Transaction.EstimateSerializeSize(1, outputs, true);
            var targetFee     = TransactionFees.FeeForSerializeSize(feePerKb, estimatedSize);

            while (true)
            {
                var funding = await fetchInputsAsync(targetAmount + targetFee);

                var inputAmount = funding.Item1;
                var inputs      = funding.Item2;
                if (inputAmount < targetAmount + targetFee)
                {
                    throw new InsufficientFundsException();
                }

                var maxSignedSize   = Transaction.EstimateSerializeSize(inputs.Length, outputs, true);
                var maxRequiredFee  = TransactionFees.FeeForSerializeSize(feePerKb, maxSignedSize);
                var remainingAmount = inputAmount - targetAmount;
                if (remainingAmount < maxRequiredFee)
                {
                    targetFee = maxRequiredFee;
                    continue;
                }

                var unsignedTransaction = new Transaction(Transaction.SupportedVersion, inputs, outputs, 0, 0);
                var changeAmount        = inputAmount - targetAmount - maxRequiredFee;
                if (changeAmount != 0 && !TransactionRules.IsDustAmount(changeAmount, Transaction.PayToPubKeyHashPkScriptSize, feePerKb))
                {
                    var changeScript = await fetchChangeAsync();

                    if (changeScript.Script.Length > Transaction.PayToPubKeyHashPkScriptSize)
                    {
                        throw new Exception("Fee estimation requires change scripts no larger than P2PKH output scripts");
                    }
                    var changeOutput = new Transaction.Output(changeAmount, Transaction.Output.LatestPkScriptVersion, changeScript.Script);

                    var outputList = unsignedTransaction.Outputs.ToList();
                    outputList.Add(changeOutput);
                    var outputsWithChange = outputList.ToArray();

                    unsignedTransaction = new Transaction(unsignedTransaction.Version, unsignedTransaction.Inputs, outputsWithChange,
                                                          unsignedTransaction.LockTime, unsignedTransaction.Expiry);
                }

                return(Tuple.Create(unsignedTransaction, inputAmount));
            }
        }
Пример #15
0
        public int SaveUsb(UsbCollection _usbCollection)
        {
            try
            {
                var AccInfo = _IUoW.Repository <CustomerAccProfile>().GetBy(x => x.WalletAccountNo == _usbCollection.FromSystemAccountNo);

                var SpecialOffer = _IUoW.Repository <SpecialOffers>().GetBy(x => x.AccTypeId == AccInfo.AccTypeId &&
                                                                            x.DefineServiceId == _usbCollection.PvId);


                string MainAuthFlag = string.Empty;

                var Accresult = _IUoW.Repository <AccMaster>().Get(a => a.WalletAccountNo == _usbCollection.FromSystemAccountNo).Select(s => s.SystemAccountNo).ToList();
                var sysAccNo  = Accresult[0];

                var max = _IUoW.Repository <UsbCollection>().GetMaxValue(x => x.BillSlNo) + 1;

                _usbCollection.BillSlNo  = max.ToString().PadLeft(3, '0');
                _usbCollection.MakeDate  = System.DateTime.Now;
                _usbCollection.TransDate = Convert.ToDateTime(DateTime.Now.ToShortDateString());
                _usbCollection.Paid      = "1";
                _usbCollection.MakeBy    = "Kabir";
                var Today     = Convert.ToDateTime(DateTime.Now.ToShortDateString());
                var StartDate = SpecialOffer.StartDate.Value.Date;
                var EndDate   = SpecialOffer.EndDate.Value.Date;

                if (Today >= StartDate && Today <= EndDate)
                {
                    _usbCollection.totalPaidAmount = _usbCollection.totalBillAmount - Convert.ToInt32(SpecialOffer.RateAmount);
                }
                else
                {
                    _usbCollection.totalPaidAmount = _usbCollection.totalBillAmount;
                }

                var result = _IUoW.Repository <UsbCollection>().Add(_usbCollection);

                #region Auth Log
                if (result == 1)
                {
                    string url = ConfigurationManager.AppSettings["LgurdaService_server"] + "/GetAuthPermissionByFunctionId/" + _usbCollection.FunctionId + "/" + _usbCollection.FunctionName + "?format=json";
                    using (WebClient wc = new WebClient())
                    {
                        TransactionRules OBJ_TransactionRules = new TransactionRules();
                        var json = wc.DownloadString(url);
                        OBJ_TransactionRules = JsonConvert.DeserializeObject <TransactionRules>(json);
                        MainAuthFlag         = OBJ_TransactionRules.GetAuthPermissionByFunctionIdResult;
                    }
                    if (MainAuthFlag == "1")
                    {
                        _IAuthLogService = new AuthLogService();
                        long _outMaxSlAuthLogDtl = 0;
                        result = _IAuthLogService.AddAuthLog(_IUoW, null, _usbCollection, "ADD", "0001", _usbCollection.FunctionId, 1, "UsbCollection", "MTK_USB_COLLECTION", "CashInId", _usbCollection.FunctionId, "prova", _outMaxSlAuthLogDtl, out _outMaxSlAuthLogDtl);
                    }
                    if (MainAuthFlag == "1")
                    {
                        _IAuthLogService = new AuthLogService();
                        FTAuthLog _ObjAuthLog = new FTAuthLog();
                        _ObjAuthLog.TableNm       = "MTK_USB_COLLECTION";
                        _ObjAuthLog.AuthStatusId  = "A";
                        _ObjAuthLog.LastAction    = "ADD";
                        _ObjAuthLog.FunctionId    = _usbCollection.FunctionId;
                        _ObjAuthLog.TablePkColVal = _usbCollection.BillSlNo;
                        result = _IAuthLogService.SetTableObject_FT <UsbCollection>(_IUoW, _ObjAuthLog, _usbCollection);
                    }
                }
                #endregion

                if (result == 1)
                {
                    _IUoW.Commit();
                }
                return(result);
            }
            catch (Exception ex)
            {
                _ObjErrorLogService = new ErrorLogService();
                _ObjErrorLogService.AddErrorLog(ex, string.Empty, "SaveUSb(obj)", string.Empty);
                return(0);
            }
        }
Пример #16
0
        public string AddFundTransfer(FundTransfer _FundTransfer)
        {
            int result = 0;

            _FundTransfer.TransDT = Convert.ToDateTime(System.DateTime.Now.ToString("dd/MM/yyyy"));
            string           split_result    = string.Empty;
            string           MainAuthFlag    = string.Empty;
            AccMasterService _AccInfoService = new AccMasterService();
            AccMaster        _AccInfo_Post   = new AccMaster();
            AccMaster        _AccInfo_Get    = new AccMaster();

            StatusWiseServiceService _StatusWiseServiceService = new StatusWiseServiceService();
            StatusWiseService        _StatusWiseService        = new StatusWiseService();
            int CheckStatusWiseService = 0;

            TransactionRulesService _TransactionRulesService = new TransactionRulesService();
            TransactionRules        _TransactionRules        = new TransactionRules();
            int CheckTransactionRules = 0;

            AccLimitSetupService _AccLimitSetupService = new AccLimitSetupService();
            AccLimitSetup        _AccLimitSetup        = new AccLimitSetup();
            string CheckAccLimit = string.Empty;

            try
            {
                #region Get SystemAccountNo by WalletAccountNo
                _AccInfo_Post.FromSystemAccountNo = _FundTransfer.FromSystemAccountNo;
                _AccInfo_Post.ToSystemAccountNo   = _FundTransfer.ToSystemAccountNo;
                _AccInfo_Post.FunctionId          = _FundTransfer.FunctionId;
                _AccInfo_Get = _AccInfoService.GetAccInfo(_AccInfo_Post);
                if (_AccInfo_Get == null || _AccInfo_Get.FromSystemAccountNo == null || _AccInfo_Get.ToSystemAccountNo == null)
                {
                    split_result = result + ":" + "Account No. not valid..";
                    return(split_result);
                }
                #endregion

                #region Check StatusWiseService
                _StatusWiseService.ToSystemAccountNo = _AccInfo_Get.ToSystemAccountNo;
                _StatusWiseService.DefineServiceId   = _FundTransfer.DefineServiceId;
                CheckStatusWiseService = _StatusWiseServiceService.CheckStatusWiseService(_StatusWiseService);
                if (CheckStatusWiseService == 0)
                {
                    split_result = result + ":" + "Account No. is not active for this transaction..";
                    return(split_result);
                }
                #endregion

                #region Check TransactionRules
                _TransactionRules.FromSystemAccountNo = _AccInfo_Get.FromSystemAccountNo;
                _TransactionRules.ToSystemAccountNo   = _AccInfo_Get.ToSystemAccountNo;
                _TransactionRules.DefineServiceId     = _FundTransfer.DefineServiceId;
                CheckTransactionRules = _TransactionRulesService.CheckTransactionRules(_TransactionRules);
                if (CheckTransactionRules == 0)
                {
                    split_result = result + ":" + "Transaction is not allowed..";
                    return(split_result);
                }
                #endregion

                #region Check Limit
                _AccLimitSetup.FromSystemAccountNo = _AccInfo_Get.FromSystemAccountNo;
                _AccLimitSetup.FromAccType         = _AccInfo_Get.FromAccType;
                _AccLimitSetup.ToSystemAccountNo   = _AccInfo_Get.ToSystemAccountNo;
                _AccLimitSetup.ToAccType           = _AccInfo_Get.ToAccType;
                _AccLimitSetup.DefineServiceId     = _FundTransfer.DefineServiceId;
                _AccLimitSetup.Amount  = _FundTransfer.Amount;
                _AccLimitSetup.TransDT = _FundTransfer.TransDT;
                CheckAccLimit          = _AccLimitSetupService.CheckAccLimit(_AccLimitSetup);
                if (CheckAccLimit != "true")
                {
                    split_result = result + ":" + CheckAccLimit;
                    return(split_result);
                }
                #endregion

                if (_AccInfo_Get.FromSystemAccountNo != null && _AccInfo_Get.ToSystemAccountNo != null && CheckStatusWiseService != 0 && CheckTransactionRules != 0 && CheckAccLimit == "true")
                {
                    var _max = _IUoW.Repository <FundTransfer>().GetMaxValue(x => x.FundTransferId) + 1;
                    _FundTransfer.FundTransferId      = _max.ToString().PadLeft(9, '0');
                    _FundTransfer.AuthStatusId        = "U";
                    _FundTransfer.LastAction          = "ADD";
                    _FundTransfer.MakeDT              = System.DateTime.Now;
                    _FundTransfer.MakeBy              = "prova";
                    _FundTransfer.FromSystemAccountNo = _AccInfo_Get.FromSystemAccountNo;
                    _FundTransfer.ToSystemAccountNo   = _AccInfo_Get.ToSystemAccountNo;
                    result = _IUoW.Repository <FundTransfer>().Add(_FundTransfer);

                    #region Auth Log
                    if (result == 1)
                    {
                        string url = ConfigurationManager.AppSettings["LgurdaService_server"] + "/GetAuthPermissionByFunctionId/" + _FundTransfer.FunctionId + "/" + _FundTransfer.FunctionName + "?format=json";
                        using (WebClient wc = new WebClient())
                        {
                            TransactionRules OBJ_TransactionRules = new TransactionRules();
                            var json = wc.DownloadString(url);
                            OBJ_TransactionRules = JsonConvert.DeserializeObject <TransactionRules>(json);
                            MainAuthFlag         = OBJ_TransactionRules.GetAuthPermissionByFunctionIdResult;
                        }
                        if (MainAuthFlag == "1")
                        {
                            _IAuthLogService = new AuthLogService();
                            long _outMaxSlAuthLogDtl = 0;
                            result = _IAuthLogService.AddAuthLog(_IUoW, null, _FundTransfer, "ADD", "0001", _FundTransfer.FunctionId, 1, "FundTransfer", "MTK_TRN_FUND_TRANSFER", "FundTransferId", _FundTransfer.FundTransferId, "prova", _outMaxSlAuthLogDtl, out _outMaxSlAuthLogDtl);
                        }
                        if (MainAuthFlag == "0")
                        {
                            _IAuthLogService = new AuthLogService();
                            FTAuthLog _ObjAuthLog = new FTAuthLog();
                            _ObjAuthLog.TableNm       = "MTK_TRN_FUND_TRANSFER";
                            _ObjAuthLog.AuthStatusId  = "A";
                            _ObjAuthLog.LastAction    = "ADD";
                            _ObjAuthLog.FunctionId    = _FundTransfer.FunctionId;
                            _ObjAuthLog.TablePkColVal = _FundTransfer.FundTransferId;
                            result = _IAuthLogService.SetTableObject_FT <FundTransfer>(_IUoW, _ObjAuthLog, _FundTransfer);
                        }
                    }
                    #endregion

                    if (result == 1)
                    {
                        _IUoW.Commit();
                        split_result = result + ":" + "Saved Successfully";
                    }
                    else
                    {
                        split_result = result + ":" + "information hasn't been added";
                    }
                }
            }
            catch (Exception ex)
            {
                _ObjErrorLogService = new ErrorLogService();
                _ObjErrorLogService.AddErrorLog(ex, string.Empty, "AddFundTransfer(obj)", string.Empty);
                split_result = result + ":" + "";
            }
            return(split_result);
        }
        public int AddCustomer(CustomerAccProfile _Customer, APIServiceRequest _requestedDataObject)
        {
            try
            {
                string FunctionId   = "090103003";
                string FunctionName = "CustomerAccProfile";
                string MainAuthFlag = string.Empty;
                string MonitoringId = "3";

                var _max = _IUoW.Repository <CustomerAccProfile>().GetMaxValue(x => x.AccountProfileId);
                if (_max > 0)
                {
                    _Customer.AccountProfileId = (_max + 1).ToString();
                }
                else
                {
                    _Customer.AccountProfileId = MonitoringId + (_max + 1).ToString().PadLeft(8, '0');
                }

                if (_Customer.sameAsPeranent == "True")
                {
                    _Customer.PermanentAddress1 = _Customer.PresentAddress1;
                    _Customer.PermanentAddress2 = _Customer.PresentAddress2;
                    _Customer.PermanentCountry  = _Customer.CountryId;
                    _Customer.PermanentDistrict = _Customer.PresentDistrict;
                    _Customer.PermanentArea     = _Customer.PresentArea;
                    _Customer.PermanentCity     = _Customer.PresentCity;
                    _Customer.PermanentThana    = _Customer.PresentThana;
                    //_Customer.PermanentPhone = _Customer.PresentPhone;
                }
                //else {
                //_Customer.AuthStatusId = "U";
                //_Customer.LastAction = "ADD";
                //_Customer.AccountStatusId = "R";
                //_Customer.MakeDT = Convert.ToDateTime(DateTime.Now.ToShortDateString());
                //_Customer.MakeBy = "mtaka";
                //}
                _Customer.SystemAccountNo = Guid.NewGuid().ToString();
                _Customer.AuthStatusId    = "U";
                _Customer.LastAction      = "ADD";
                _Customer.AccountStatusId = "001";
                _Customer.MakeDT          = System.DateTime.Now;
                _Customer.MakeBy          = "mtaka";
                var result = _IUoW.Repository <CustomerAccProfile>().Add(_Customer);

                #region Auth Log
                if (result == 1)
                {
                    string url = ConfigurationManager.AppSettings["LgurdaService_server"] + "/GetAuthPermissionByFunctionId/" + FunctionId + "/" + FunctionName + "?format=json";
                    using (WebClient wc = new WebClient())
                    {
                        TransactionRules OBJ_TransactionRules = new TransactionRules();
                        var json = wc.DownloadString(url);
                        OBJ_TransactionRules = JsonConvert.DeserializeObject <TransactionRules>(json);
                        MainAuthFlag         = OBJ_TransactionRules.GetAuthPermissionByFunctionIdResult;
                    }
                    if (MainAuthFlag == "1")
                    {
                        #region Data Store in Account Info
                        if (result == 1)
                        {
                            _AccInfo = new AccMaster();
                            var _maxAccInfoId = _IUoW.Repository <AccMaster>().GetMaxValue(x => x.AccountId) + 1;
                            _AccInfo.AccountId = _maxAccInfoId.ToString().PadLeft(3, '0');
                            //_AccInfo.AccProfileId = _Customer.AccountProfileId;
                            _AccInfo.WalletAccountNo = _Customer.WalletAccountNo;
                            _AccInfo.SystemAccountNo = _Customer.SystemAccountNo;
                            //_AccInfo.AccNm = _Customer.CustomerNm;
                            _AccInfo.AccTypeId       = _Customer.AccTypeId;
                            _AccInfo.BankAccountNo   = _Customer.BankAccountNo;
                            _AccInfo.TransDT         = Convert.ToDateTime(System.DateTime.Now.ToString("dd/MM/yyyy"));
                            _AccInfo.AccountStatusId = "001";
                            _AccInfo.AuthStatusId    = "U";
                            _AccInfo.LastAction      = "ADD";
                            _AccInfo.MakeDT          = System.DateTime.Now;
                            _AccInfo.MakeBy          = "mTaka";

                            _IUoW.Repository <AccMaster>().Add(_AccInfo);
                        }
                        #endregion

                        _IAuthLogService = new AuthLogService();
                        long _outMaxSlAuthLogDtl = 0;
                        result = _IAuthLogService.AddAuthLog(_IUoW, null, _Customer, "ADD", "0001", _Customer.FunctionId, 1, "CustomerAccProfile", "MTK_ACC_CUSTOMER_ACC_PROFILE", "AccountProfileId", _Customer.AccountProfileId, _Customer.UserName, _outMaxSlAuthLogDtl, out _outMaxSlAuthLogDtl);
                    }
                    if (MainAuthFlag == "0")
                    {
                        _IAuthLogService = new AuthLogService();
                        AuthLog _ObjAuthLog = new AuthLog();
                        _ObjAuthLog.TableNm       = "MTK_ACC_CUSTOMER_ACC_PROFILE";
                        _ObjAuthLog.AuthStatusId  = "A";
                        _ObjAuthLog.LastAction    = "ADD";
                        _ObjAuthLog.FunctionId    = FunctionId;
                        _ObjAuthLog.TablePkColVal = _Customer.AccountProfileId;
                        _ObjAuthLog.MainAuthFlag  = MainAuthFlag;

                        //_Customer.AccIdofAccInfo = _AccInfo.AccountId;

                        result = _IAuthLogService.SetTableObject <CustomerAccProfile>(_IUoW, _ObjAuthLog, _Customer);

                        if (result == 1) //For Creating User in Lguarda
                        {
                            string _UserId = _Customer.WalletAccountNo;
                            string _MakeBy = _requestedDataObject.UserId;
                            string _UserClassificationId = "2";
                            string _UserAreaId           = "5";
                            string _UserAreaIdValue      = _Customer.SystemAccountNo;
                            string _UserDescription      = "null";
                            string _BranchId             = "null";
                            string _CustomerFatherNm     = string.IsNullOrWhiteSpace(_Customer.FatherName) ? "null" : _Customer.FatherName;
                            string _CustomerMotherNm     = string.IsNullOrWhiteSpace(_Customer.MotherName) ? "null" : _Customer.MotherName;
                            //string _CustomerDOB = (_Customer.CustomerDOB == null) ? "null" : DateTime.ParseExact(_Customer.CustomerDOB.ToString(), "dd-MM-yyyy", CultureInfo.InvariantCulture).ToString();
                            string _CustomerDOB      = "null";
                            string _AccNo            = _Customer.WalletAccountNo;
                            string _MailAddress      = string.IsNullOrWhiteSpace(_Customer.Email) ? "null" : _Customer.Email;
                            string _MobNo            = string.IsNullOrWhiteSpace(_Customer.AlternativeMblNo) ? _Customer.WalletAccountNo : _Customer.AlternativeMblNo;
                            string _AuthenticationId = "5";
                            string _WorkCriteria     = "2";
                            string _RoleId           = "29";
                            string _RequestClientIP  = string.IsNullOrWhiteSpace(_requestedDataObject.RequestClientIP) ? "null" : _requestedDataObject.RequestClientIP;
                            string _RequestAppId     = string.IsNullOrWhiteSpace(_requestedDataObject.RequestAppId) ? "09" : _requestedDataObject.RequestAppId;
                            string url1 = ConfigurationManager.AppSettings["LgurdaService_server"] + "/Add_UserProfile/" + _UserId + "/" + _MakeBy + "/" +
                                          _UserClassificationId + "/" + _UserAreaId + "/" +
                                          _UserAreaIdValue + "/" + _Customer.UserName + "/" +
                                          _UserDescription + "/" + _BranchId + "/" +
                                          _AccNo + "/" + _CustomerFatherNm + "/" +
                                          _CustomerMotherNm + "/" + _CustomerDOB + "/" +
                                          _MailAddress + "/" + _MobNo + "/" +
                                          _AuthenticationId + "/" + _RequestClientIP + "/" +
                                          "null" + "/" + "null" + "/" +
                                          _WorkCriteria + "/" + _RequestAppId + "/" + "A" + "/" + _RoleId + "?format=json";
                            string lg_result = PostParameter(url1);
                            result = (!string.IsNullOrWhiteSpace(lg_result) && lg_result.ToLower() == "true") ? 1 : 0;
                        }
                    }
                }
                #endregion
                //#region Auth Log
                //if (result == 1)
                //{
                //    _IAuthLogService = new AuthLogService();
                //    long _outMaxSlAuthLogDtl = 0;
                //    result = _IAuthLogService.AddAuthLog(_IUoW, null, _Customer, "ADD", "0001", "090103003", 1, "MTK_ACC_CUSTOMER_ACC_PROFILE", "AccountProfileId", _Customer.AccountProfileId, "mtaka", _outMaxSlAuthLogDtl, out _outMaxSlAuthLogDtl);
                //}
                //#endregion
                if (result == 1)
                {
                    _IUoW.Commit();
                }
                return(result);
            }
            catch (Exception ex)
            {
                _ObjErrorLogService = new ErrorLogService();
                _ObjErrorLogService.AddErrorLog(ex, string.Empty, "AddCustomer(obj)", string.Empty);
                return(0);
            }
        }
        public int CheckTransactionRules(TransactionRules _TransactionRules)
        {
            int Check = 0;
            TransactionRules _Transaction_Rules = null;

            try
            {
                var _Acc_Info_From = _IUoW.Repository <AccMaster>().GetBy(x => x.AuthStatusId == "A" && x.LastAction != "DEL" &&
                                                                          x.SystemAccountNo == _TransactionRules.FromSystemAccountNo);
                var _Acc_Info_To = _IUoW.Repository <AccMaster>().GetBy(x => x.AuthStatusId == "A" && x.LastAction != "DEL" &&
                                                                        x.SystemAccountNo == _TransactionRules.ToSystemAccountNo);

                if (_Acc_Info_From != null && _Acc_Info_To != null)
                {
                    if (_TransactionRules.DefineServiceId == "001")
                    {
                        _Transaction_Rules = _IUoW.Repository <TransactionRules>().GetBy(x => x.AuthStatusId == "A" && x.LastAction != "DEL" &&
                                                                                         x.AccountType1 == _Acc_Info_From.AccTypeId && x.DefineServiceId == _TransactionRules.DefineServiceId &&
                                                                                         x.AccountType2 == _Acc_Info_To.AccTypeId);
                    }
                    if (_TransactionRules.DefineServiceId == "002")
                    {
                        _Transaction_Rules = _IUoW.Repository <TransactionRules>().GetBy(x => x.AuthStatusId == "A" && x.LastAction != "DEL" &&
                                                                                         x.AccountType1 == _Acc_Info_To.AccTypeId && x.DefineServiceId == _TransactionRules.DefineServiceId &&
                                                                                         x.AccountType2 == _Acc_Info_From.AccTypeId);
                    }
                    if (_TransactionRules.DefineServiceId == "003")
                    {
                        _Transaction_Rules = _IUoW.Repository <TransactionRules>().GetBy(x => x.AuthStatusId == "A" && x.LastAction != "DEL" &&
                                                                                         x.AccountType1 == _Acc_Info_From.AccTypeId && x.DefineServiceId == _TransactionRules.DefineServiceId &&
                                                                                         x.AccountType2 == _Acc_Info_To.AccTypeId);
                    }
                    if (_TransactionRules.DefineServiceId == "004")
                    {
                        _Transaction_Rules = _IUoW.Repository <TransactionRules>().GetBy(x => x.AuthStatusId == "A" && x.LastAction != "DEL" &&
                                                                                         x.AccountType1 == _Acc_Info_To.AccTypeId && x.DefineServiceId == _TransactionRules.DefineServiceId &&
                                                                                         x.AccountType2 == _Acc_Info_From.AccTypeId);
                    }
                    if (_TransactionRules.DefineServiceId == "011")
                    {
                        _Transaction_Rules = _IUoW.Repository <TransactionRules>().GetBy(x => x.AuthStatusId == "A" && x.LastAction != "DEL" &&
                                                                                         x.AccountType1 == _Acc_Info_To.AccTypeId && x.DefineServiceId == _TransactionRules.DefineServiceId &&
                                                                                         x.AccountType2 == _Acc_Info_From.AccTypeId);
                    }
                    if (_Transaction_Rules != null)
                    {
                        if (_Transaction_Rules.TranactionAllowed == "0")
                        {
                            Check = 0;
                        }
                        if (_Transaction_Rules.TranactionAllowed == "1")
                        {
                            Check = 1;
                        }
                    }
                }
                return(Check);
            }
            catch (Exception ex)
            {
                _ObjErrorLogService = new ErrorLogService();
                _ObjErrorLogService.AddErrorLog(ex, string.Empty, "CheckStatusWiseService(obj)", string.Empty);
                return(Check);
            }
        }