public ActionResult Configure(FeedBecomeModel model) { if (!ModelState.IsValid) { return(Configure()); } //save settings _becomeSettings.ProductPictureSize = model.ProductPictureSize; _becomeSettings.CurrencyId = model.CurrencyId; _settingService.SaveSetting(_becomeSettings); SuccessNotification(_localizationService.GetResource("Admin.Plugins.Saved")); //redisplay the form foreach (var c in _currencyService.GetAllCurrencies(false)) { model.AvailableCurrencies.Add(new SelectListItem() { Text = c.Name, Value = c.Id.ToString() }); } return(View("~/Plugins/Feed.Become/Views/FeedBecome/Configure.cshtml", model)); }
public ActionResult GenerateFeed(FeedBecomeModel model) { if (!ModelState.IsValid) { return(Configure()); } try { string fileName = string.Format("become_{0}_{1}.csv", DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss"), CommonHelper.GenerateRandomDigitCode(4)); string filePath = Path.Combine(Request.PhysicalApplicationPath, "content\\files\\exportimport", fileName); using (var fs = new FileStream(filePath, FileMode.Create, FileAccess.Write, FileShare.ReadWrite)) { var pluginDescriptor = _pluginFinder.GetPluginDescriptorBySystemName("PromotionFeed.Become"); if (pluginDescriptor == null) { throw new Exception("Cannot load the plugin"); } //plugin var plugin = pluginDescriptor.Instance() as BecomeService; if (plugin == null) { throw new Exception("Cannot load the plugin"); } plugin.GenerateFeed(fs, _storeContext.CurrentStore); } string clickhereStr = string.Format("<a href=\"{0}content/files/exportimport/{1}\" target=\"_blank\">{2}</a>", _webHelper.GetStoreLocation(false), fileName, _localizationService.GetResource("Plugins.Feed.Become.ClickHere")); string result = string.Format(_localizationService.GetResource("Plugins.Feed.Become.SuccessResult"), clickhereStr); model.GenerateFeedResult = result; } catch (Exception exc) { model.GenerateFeedResult = exc.Message; _logger.Error(exc.Message, exc); } foreach (var c in _currencyService.GetAllCurrencies(false)) { model.AvailableCurrencies.Add(new SelectListItem() { Text = c.Name, Value = c.Id.ToString() }); } return(View("~/Plugins/Feed.Become/Views/FeedBecome/Configure.cshtml", model)); }
public ActionResult Configure() { var model = new FeedBecomeModel(); model.ProductPictureSize = _becomeSettings.ProductPictureSize; model.CurrencyId = _becomeSettings.CurrencyId; foreach (var c in _currencyService.GetAllCurrencies(false)) { model.AvailableCurrencies.Add(new SelectListItem() { Text = c.Name, Value = c.Id.ToString() }); } return(View("Nop.Plugin.Feed.Become.Views.FeedBecome.Configure", model)); }
public ActionResult Configure() { var model = new FeedBecomeModel { ProductPictureSize = _becomeSettings.ProductPictureSize, CurrencyId = _becomeSettings.CurrencyId }; foreach (var c in _currencyService.GetAllCurrencies(false)) { model.AvailableCurrencies.Add(new SelectListItem() { Text = c.Name, Value = c.Id.ToString() }); } return(View("~/Plugins/Feed.Become/Views/FeedBecome/Configure.cshtml", model)); }
public ActionResult GenerateFeed(FeedBecomeModel model) { if (!ModelState.IsValid) { return(Configure()); } try { string fileName = string.Format("become_{0}_{1}.csv", DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss"), CommonHelper.GenerateRandomDigitCode(4)); string filePath = string.Format("{0}content\\files\\exportimport\\{1}", Request.PhysicalApplicationPath, fileName); using (var fs = new FileStream(filePath, FileMode.Create, FileAccess.Write, FileShare.ReadWrite)) { var feed = _promotionFeedService.LoadPromotionFeedBySystemName("PromotionFeed.Become"); feed.GenerateFeed(fs); } string clickhereStr = string.Format("<a href=\"{0}content/files/exportimport/{1}\" target=\"_blank\">{2}</a>", _webHelper.GetStoreLocation(false), fileName, _localizationService.GetResource("Plugins.Feed.Become.ClickHere")); string result = string.Format(_localizationService.GetResource("Plugins.Feed.Become.SuccessResult"), clickhereStr); model.GenerateFeedResult = result; } catch (Exception exc) { model.GenerateFeedResult = exc.Message; _logger.Error(exc.Message, exc); } foreach (var c in _currencyService.GetAllCurrencies(false)) { model.AvailableCurrencies.Add(new SelectListItem() { Text = c.Name, Value = c.Id.ToString() }); } return(View("Nop.Plugin.Feed.Become.Views.FeedBecome.Configure", model)); }
public ActionResult Configure(FeedBecomeModel model) { if (!ModelState.IsValid) { return(Configure()); } //save settings _becomeSettings.ProductPictureSize = model.ProductPictureSize; _becomeSettings.CurrencyId = model.CurrencyId; _settingService.SaveSetting(_becomeSettings); //redisplay the form foreach (var c in _currencyService.GetAllCurrencies(false)) { model.AvailableCurrencies.Add(new SelectListItem() { Text = c.Name, Value = c.Id.ToString() }); } return(View("Nop.Plugin.Feed.Become.Views.FeedBecome.Configure", model)); }