public ActionResult SettingsSelections(SettingsSelectionsModel selectionsModel) { var data = _settingsRepository.RetrieveSettings(); // Save Settings // data.AcumaticaTimeZone = selectionsModel.AcumaticaTimeZone; data.AcumaticaDefaultItemClass = selectionsModel.AcumaticaDefaultItemClass; data.AcumaticaDefaultPostingClass = selectionsModel.AcumaticaDefaultPostingClass; data.AcumaticaCustomerClass = selectionsModel.AcumaticaDefaultCustomerClass; _settingsRepository.SaveChanges(); // Save Gateways // var gatewayRecords = selectionsModel.PaymentGateways.Select(x => new PaymentGateway() { ShopifyGatewayId = x.ShopifyGatewayId, AcumaticaCashAccount = x.AcumaticaCashAcount, AcumaticaPaymentMethod = x.AcumaticaPaymentMethod, }) .ToList(); _settingsRepository.ImprintPaymentGateways(gatewayRecords); // Save Carrier-to-Ship-Via mappings // var carrierToShipVia = selectionsModel.RateToShipVias.Select(x => new RateToShipVia() { ShopifyRateName = x.ShopifyRateName, AcumaticaShipViaId = x.AcumaticaCarrierId, }) .ToList(); _settingsRepository.ImprintRateToShipVias(carrierToShipVia); // Refresh the Settings Status // _statusService.RefreshSettingsStatus(); return(JsonNetResult.Success()); }
public ActionResult SettingsSelections() { var output = new SettingsSelectionsModel(); var settings = _settingsRepository.RetrieveSettings(); output.AcumaticaTimeZone = settings.AcumaticaTimeZone; output.AcumaticaDefaultItemClass = settings.AcumaticaDefaultItemClass; output.AcumaticaDefaultPostingClass = settings.AcumaticaDefaultPostingClass; output.AcumaticaDefaultCustomerClass = settings.AcumaticaCustomerClass; var selectedGateways = _settingsRepository.RetrievePaymentGateways(); foreach (var selectedGateway in selectedGateways) { var gateway = new PaymentGatewaySelectionModel(); gateway.ShopifyGatewayId = selectedGateway.ShopifyGatewayId; gateway.ShopifyGatewayName = _gatewayService.Name(selectedGateway.ShopifyGatewayId); gateway.AcumaticaPaymentMethod = selectedGateway.AcumaticaPaymentMethod; gateway.AcumaticaCashAcount = selectedGateway.AcumaticaCashAccount; output.PaymentGateways.Add(gateway); } var selectedCarriers = _settingsRepository.RetrieveRateToShipVias(); foreach (var selectedCarrier in selectedCarriers) { var rate = new CarrierToShipViaSelection(); rate.ShopifyRateName = selectedCarrier.ShopifyRateName; rate.AcumaticaCarrierId = selectedCarrier.AcumaticaShipViaId; output.RateToShipVias.Add(rate); } return(new JsonNetResult(output)); }