public async Task <IActionResult> AssignOperatorToMerchant(AssignOperatorToMerchantViewModel viewModel,
                                                                   CancellationToken cancellationToken)
        {
            if (!ModelState.IsValid)
            {
                return(PartialView("_AssignOperatorToMerchant", viewModel));
            }

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

            AssignOperatorToMerchantModel model = this.ViewModelFactory.ConvertFrom(viewModel);

            try
            {
                await this.ApiClient.AssignOperatorToMerchant(accessToken, this.User.Identity as ClaimsIdentity, viewModel.MerchantId, model, cancellationToken);

                return(this.RedirectToAction("GetMerchant",
                                             new
                {
                    merchantId = viewModel.MerchantId
                }).WithSuccess("Operator Assigned Successfully", $"Operator Assigned successfully for Merchant"));
            }
            catch (Exception e)
            {
                return(this.RedirectToAction("GetMerchant",
                                             new
                {
                    merchantId = viewModel.MerchantId
                }).WithWarning("Operator Assign Failed", Helpers.BuildUserErrorMessage("Failed to assign Operator to Merchant")));
            }
        }
        public ActionResult AssignOperatorToMerchant(Guid merchantId,
                                                     CancellationToken cancellationToken)
        {
            AssignOperatorToMerchantViewModel viewModel = new AssignOperatorToMerchantViewModel();

            viewModel.MerchantId = merchantId;

            return(this.PartialView("_AssignOperatorToMerchant", viewModel));
        }
        /// <summary>
        /// Converts from.
        /// </summary>
        /// <param name="assignOperatorToMerchantViewModel">The assign operator to merchant view model.</param>
        /// <returns></returns>
        public AssignOperatorToMerchantModel ConvertFrom(AssignOperatorToMerchantViewModel assignOperatorToMerchantViewModel)
        {
            if (assignOperatorToMerchantViewModel == null)
            {
                throw new ArgumentNullException(nameof(assignOperatorToMerchantViewModel));
            }

            AssignOperatorToMerchantModel model = new AssignOperatorToMerchantModel
            {
                MerchantNumber = assignOperatorToMerchantViewModel.MerchantNumber,
                TerminalNumber = assignOperatorToMerchantViewModel.TerminalNumber,
                OperatorId     = assignOperatorToMerchantViewModel.OperatorId
            };

            return(model);
        }