public async Task <IActionResult> AddMerchantDevice(AddMerchantDeviceViewModel viewModel, CancellationToken cancellationToken)
        {
            if (!ModelState.IsValid)
            {
                return(PartialView("_AddMerchantDevice", viewModel));
            }

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

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

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

                return(this.RedirectToAction("GetMerchant",
                                             new
                {
                    merchantId = viewModel.MerchantId
                }).WithSuccess("Device Added Successfully", $"Device added successfully for Merchant"));
            }
            catch (Exception e)
            {
                return(this.RedirectToAction("GetMerchant",
                                             new
                {
                    merchantId = viewModel.MerchantId
                }).WithWarning("Device Add Failed", Helpers.BuildUserErrorMessage("Failed to add device to Merchant")));
            }
        }
        /// <summary>
        /// Converts from.
        /// </summary>
        /// <param name="addMerchantDeviceViewModel">The add merchant device view model.</param>
        /// <returns></returns>
        /// <exception cref="ArgumentNullException">addMerchantDeviceViewModel</exception>
        public AddMerchantDeviceModel ConvertFrom(AddMerchantDeviceViewModel addMerchantDeviceViewModel)
        {
            if (addMerchantDeviceViewModel == null)
            {
                throw new ArgumentNullException(nameof(addMerchantDeviceViewModel));
            }

            AddMerchantDeviceModel model = new AddMerchantDeviceModel
            {
                DeviceIdentifier = addMerchantDeviceViewModel.DeviceIdentifier
            };

            return(model);
        }