public async Task <IActionResult> GetContractProductTransactionFeesListAsJson([FromQuery] Guid contractId,
                                                                                      [FromQuery] Guid contractProductId,
                                                                                      CancellationToken cancellationToken)
        {
            try
            {
                // Search Value from (Search box)
                String searchValue = this.HttpContext.Request.Form["search[value]"].FirstOrDefault();

                String accessToken = await this.HttpContext.GetTokenAsync("access_token");

                ContractProductModel contractProduct =
                    await this.ApiClient.GetContractProduct(accessToken, this.User.Identity as ClaimsIdentity, contractId, contractProductId, cancellationToken);

                ContractProductTransactionFeesListViewModel contractProductTransactionFeesViewModel = this.ViewModelFactory.ConvertFrom(contractProduct);

                Expression <Func <ContractProductTransactionFeesViewModel, Boolean> > whereClause =
                    c => c.Description.Contains(searchValue, StringComparison.OrdinalIgnoreCase) ||
                    c.CalculationType.Contains(searchValue, StringComparison.OrdinalIgnoreCase) ||
                    c.FeeType.Contains(searchValue, StringComparison.OrdinalIgnoreCase) || c.Value.Contains(searchValue, StringComparison.OrdinalIgnoreCase);

                return(this.Json(Helpers.GetDataForDataTable(this.Request.Form, contractProductTransactionFeesViewModel.TransactionFees, whereClause)));
            }
            catch (Exception e)
            {
                return(this.Json(Helpers.GetErrorDataForDataTable <String>(Helpers.BuildUserErrorMessage("Error getting contract product transaction fee list"))));
            }
        }
        public async Task <IActionResult> GetContractProductTransactionFeesList([FromQuery] Guid contractId,
                                                                                [FromQuery] Guid contractProductId,
                                                                                CancellationToken cancellationToken)
        {
            try
            {
                String accessToken = await this.HttpContext.GetTokenAsync("access_token");

                ContractProductModel contractProduct =
                    await this.ApiClient.GetContractProduct(accessToken, this.User.Identity as ClaimsIdentity, contractId, contractProductId, cancellationToken);

                ContractProductTransactionFeesListViewModel viewModel = this.ViewModelFactory.ConvertFrom(contractProduct);

                return(this.View("ContractProductTransactionFeesList", viewModel));
            }
            catch (Exception e)
            {
                return(this.View("ContractProductsList", new ContractProductListViewModel())
                       .WithWarning("Contract Product Transaction Fees", Helpers.BuildUserErrorMessage("Error getting a list of transaction fees for product")));
            }
        }
        /// <summary>
        /// Converts from.
        /// </summary>
        /// <param name="contractProduct">The contract product.</param>
        /// <returns></returns>
        /// <exception cref="ArgumentNullException">contractProduct</exception>
        public ContractProductTransactionFeesListViewModel ConvertFrom(ContractProductModel contractProduct)
        {
            if (contractProduct == null)
            {
                throw new ArgumentNullException(nameof(contractProduct));
            }

            ContractProductTransactionFeesListViewModel viewModel = new ContractProductTransactionFeesListViewModel
            {
                ContractProductId = contractProduct.ContractProductId,
                ProductName       = contractProduct.ProductName,
                Description       = contractProduct.Description,
                Value             = contractProduct.Value.HasValue ? contractProduct.Value.Value.ToString() : "Variable",
                ContractId        = contractProduct.ContractId,
                TransactionFees   = new List <ContractProductTransactionFeesViewModel>(),
            };

            if (contractProduct.ContractProductTransactionFees != null && contractProduct.ContractProductTransactionFees.Any())
            {
                foreach (ContractProductTransactionFeeModel transactionFee in contractProduct.ContractProductTransactionFees)
                {
                    viewModel.TransactionFees.Add(new ContractProductTransactionFeesViewModel
                    {
                        Description       = transactionFee.Description,
                        Value             = transactionFee.Value,
                        CalculationType   = transactionFee.CalculationType,
                        FeeType           = transactionFee.FeeType,
                        ContractId        = contractProduct.ContractId,
                        ContractProductId = contractProduct.ContractProductId,
                        TransactionFeeId  = transactionFee.TransactionFeeId,
                        EstateId          = contractProduct.EstateId
                    });
                }
            }

            return(viewModel);
        }