public static void SetCoinSwitchSettings(this StoreBlob storeBlob, CoinSwitchSettings settings) { if (settings is null) { storeBlob.AdditionalData.Remove(StoreBlobKey); } else { storeBlob.AdditionalData.AddOrReplace(StoreBlobKey, JObject.FromObject(settings)); } }
public async Task <IActionResult> UpdateCoinSwitchSettings(string storeId, UpdateCoinSwitchSettingsViewModel vm, string command) { var store = HttpContext.GetStoreData(); if (store == null) { return(NotFound()); } if (vm.Enabled) { if (!ModelState.IsValid) { return(View(vm)); } } var coinSwitchSettings = new CoinSwitchSettings() { MerchantId = vm.MerchantId, Enabled = vm.Enabled, Mode = vm.Mode, AmountMarkupPercentage = vm.AmountMarkupPercentage }; switch (command) { case "save": var storeBlob = store.GetStoreBlob(); storeBlob.SetCoinSwitchSettings(coinSwitchSettings); store.SetStoreBlob(storeBlob); await _storeRepository.UpdateStore(store); TempData[WellKnownTempData.SuccessMessage] = "CoinSwitch settings modified"; return(RedirectToAction(nameof(UpdateCoinSwitchSettings), new { storeId })); default: return(View(vm)); } }