public IActionResult TestConnection() { KachingConfigurationModel model = GetBaseModel(); try { POSKachingService service = new POSKachingService(_logger, _kachingSettings, _settingService, _pictureService, _productAttributeService); if (service.TestConnection()) { model.KachingAliveValue = "Kaching is alive"; } else { model.KachingIsDead = "Kaching is dead"; } } catch (Exception ex) { Exception inner = ex; while (inner.InnerException != null) { inner = inner.InnerException; } _logger.Error("Configure POS Kaching: " + inner.Message, ex); model.ErrorMessage += "<br />" + inner.Message; } return(View("~/Plugins/Nop.Plugin.POS.Kaching/Views/Configure.cshtml", model)); }
public IActionResult SendAllProducts() { KachingConfigurationModel model = GetBaseModel(); if (this._kachingSettings.POSKaChingActive) { IPagedList <Core.Domain.Catalog.Product> products = _productService.SearchProducts(); int count = 0; foreach (Core.Domain.Catalog.Product product in products) { try { POSKachingService service = new POSKachingService(_logger, _kachingSettings, _settingService, _pictureService, _productAttributeService); var json = service.BuildJSONString(product); service.SaveProduct(json); count++; } catch (Exception ex) { Exception inner = ex; while (inner.InnerException != null) { inner = inner.InnerException; } _logger.Error("Configure POS Kaching: " + inner.Message, ex); model.ErrorMessage += "<br />" + inner.Message; } } if (count > 0) { model.ProductsTransferred = "Products transferred: " + count; } } else { model.ErrorMessage = "Kaching is not active"; } return(View("~/Plugins/Nop.Plugin.POS.Kaching/Views/Configure.cshtml", model)); }