public ActionResult Create(CommerceInstanceEditorModel model, string @return) { var metadata = new CommerceInstanceSettings { Name = model.Name, DisplayName = model.DisplayName, DbSchema = model.DbSchema }; var dbProviderKeyParts = model.DbProviderKey.Split('|'); metadata.DbProviderInvariantName = dbProviderKeyParts[0]; metadata.DbProviderManifestToken = dbProviderKeyParts[1]; if (model.AdvancedMode) { metadata.ConnectionString = model.ConnectionString; } else { foreach (var param in model.ConnectionStringParameters) { metadata.ConnectionStringParameters.Add(param.Text, param.Value); } } _instanceManager.CreateInstance(metadata); return AjaxForm().RedirectTo(@return); }
public ActionResult Create() { var model = new CommerceInstanceEditorModel(); foreach (var provider in CommerceDbProviders.Providers) { model.AddDbProvider(provider); } return View(model); }
public ActionResult Edit(string name) { var metadata = _instanceManager.GetInstanceSettings(name); var dbProvider = CommerceDbProviders.Providers.Find(metadata.DbProviderInvariantName, metadata.DbProviderManifestToken); var model = new CommerceInstanceEditorModel { IsNew = false, Name = name, DisplayName = metadata.DisplayName, DbSchema = metadata.DbSchema, DbProviderDisplayName = dbProvider.DisplayName, DbProviderKey = dbProvider.InvariantName + "|" + dbProvider.ManifestToken, ConnectionString = metadata.ConnectionString, ConnectionStringParameters = metadata.ConnectionStringParameters.Select(x => new SelectListItem { Text = x.Key, Value = x.Value }) .ToList() }; model.AdvancedMode = !String.IsNullOrEmpty(model.ConnectionString); foreach (var provider in CommerceDbProviders.Providers) { model.AddDbProvider(provider); } return View(model); }
public ActionResult Edit(CommerceInstanceEditorModel model, string @return) { var settings = _instanceManager.GetInstanceSettings(model.Name); settings.DisplayName = model.DisplayName; if (model.AdvancedMode) { settings.ConnectionString = model.ConnectionString; } else { settings.ConnectionString = null; settings.ConnectionStringParameters.Clear(); foreach (var param in model.ConnectionStringParameters) { settings.ConnectionStringParameters.Add(param.Text, param.Value); } } var manager = new CommerceInstanceSettingsManager(); manager.Update(model.Name, settings); return AjaxForm().RedirectTo(@return); }