示例#1
0
        public async Task <IActionResult> CheckoutExperience(CheckoutExperienceViewModel model)
        {
            CurrencyValue lightningMaxValue = null;

            if (!string.IsNullOrWhiteSpace(model.LightningMaxValue))
            {
                if (!CurrencyValue.TryParse(model.LightningMaxValue, out lightningMaxValue))
                {
                    ModelState.AddModelError(nameof(model.LightningMaxValue), "Invalid lightning max value");
                }
            }

            CurrencyValue onchainMinValue = null;

            if (!string.IsNullOrWhiteSpace(model.OnChainMinValue))
            {
                if (!CurrencyValue.TryParse(model.OnChainMinValue, out onchainMinValue))
                {
                    ModelState.AddModelError(nameof(model.OnChainMinValue), "Invalid on chain min value");
                }
            }
            bool needUpdate = false;
            var  blob       = StoreData.GetStoreBlob();

            if (StoreData.GetDefaultCrypto() != model.DefaultCryptoCurrency)
            {
                needUpdate = true;
                StoreData.SetDefaultCrypto(model.DefaultCryptoCurrency);
            }
            model.SetCryptoCurrencies(_ExplorerProvider, model.DefaultCryptoCurrency);
            model.SetLanguages(_LangService, model.DefaultLang);

            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            blob.DefaultLang         = model.DefaultLang;
            blob.AllowCoinConversion = model.AllowCoinConversion;
            blob.RequiresRefundEmail = model.RequiresRefundEmail;
            blob.LightningMaxValue   = lightningMaxValue;
            blob.OnChainMinValue     = onchainMinValue;
            blob.CustomLogo          = string.IsNullOrWhiteSpace(model.CustomLogo) ? null : new Uri(model.CustomLogo, UriKind.Absolute);
            blob.CustomCSS           = string.IsNullOrWhiteSpace(model.CustomCSS) ? null : new Uri(model.CustomCSS, UriKind.Absolute);
            blob.HtmlTitle           = string.IsNullOrWhiteSpace(model.HtmlTitle) ? null : model.HtmlTitle;
            if (StoreData.SetStoreBlob(blob))
            {
                needUpdate = true;
            }
            if (needUpdate)
            {
                await _Repo.UpdateStore(StoreData);

                StatusMessage = "Store successfully updated";
            }

            return(RedirectToAction(nameof(CheckoutExperience), new
            {
                storeId = StoreData.Id
            }));
        }
示例#2
0
        public IActionResult CheckoutExperience()
        {
            var storeBlob = StoreData.GetStoreBlob();
            var vm        = new CheckoutExperienceViewModel();

            vm.SetCryptoCurrencies(_ExplorerProvider, StoreData.GetDefaultCrypto(_NetworkProvider));
            vm.SetLanguages(_LangService, storeBlob.DefaultLang);
            vm.LightningMaxValue   = storeBlob.LightningMaxValue?.ToString() ?? "";
            vm.OnChainMinValue     = storeBlob.OnChainMinValue?.ToString() ?? "";
            vm.RequiresRefundEmail = storeBlob.RequiresRefundEmail;
            vm.CustomCSS           = storeBlob.CustomCSS?.AbsoluteUri;
            vm.CustomLogo          = storeBlob.CustomLogo?.AbsoluteUri;
            vm.HtmlTitle           = storeBlob.HtmlTitle;
            return(View(vm));
        }
示例#3
0
        public async Task <IActionResult> CheckoutExperience(string storeId, CheckoutExperienceViewModel model)
        {
            CurrencyValue currencyValue = null;

            if (!string.IsNullOrWhiteSpace(model.LightningMaxValue))
            {
                if (!CurrencyValue.TryParse(model.LightningMaxValue, out currencyValue))
                {
                    ModelState.AddModelError(nameof(model.LightningMaxValue), "Invalid currency value");
                }
            }
            var store = await _Repo.FindStore(storeId, GetUserId());

            if (store == null)
            {
                return(NotFound());
            }
            bool needUpdate = false;
            var  blob       = store.GetStoreBlob();

            if (store.GetDefaultCrypto() != model.DefaultCryptoCurrency)
            {
                needUpdate = true;
                store.SetDefaultCrypto(model.DefaultCryptoCurrency);
            }
            model.SetCryptoCurrencies(_ExplorerProvider, model.DefaultCryptoCurrency);
            model.SetLanguages(_LangService, model.DefaultLang);
            blob.DefaultLang         = model.DefaultLang;
            blob.AllowCoinConversion = model.AllowCoinConversion;
            blob.LightningMaxValue   = currencyValue;
            blob.CustomLogo          = model.CustomLogo;
            blob.CustomCSS           = model.CustomCSS;
            if (store.SetStoreBlob(blob))
            {
                needUpdate = true;
            }
            if (needUpdate)
            {
                await _Repo.UpdateStore(store);

                StatusMessage = "Store successfully updated";
            }

            return(RedirectToAction(nameof(CheckoutExperience), new
            {
                storeId = storeId
            }));
        }
示例#4
0
        public async Task <IActionResult> CheckoutExperience(string storeId)
        {
            var store = await _Repo.FindStore(storeId, GetUserId());

            if (store == null)
            {
                return(NotFound());
            }
            var storeBlob = store.GetStoreBlob();
            var vm        = new CheckoutExperienceViewModel();

            vm.SetCryptoCurrencies(_ExplorerProvider, store.GetDefaultCrypto());
            vm.SetLanguages(_LangService, storeBlob.DefaultLang);
            vm.LightningMaxValue   = storeBlob.LightningMaxValue?.ToString() ?? "";
            vm.AllowCoinConversion = storeBlob.AllowCoinConversion;
            vm.CustomCSS           = storeBlob.CustomCSS;
            vm.CustomLogo          = storeBlob.CustomLogo;
            return(View(vm));
        }