public virtual IEnumerable <CommerceSetting> GetAll() { List <CommerceSetting> lst = new List <CommerceSetting>(); string[] folders = Directory.GetDirectories(this._commerceDataDir.DataPhysicalFolder); foreach (string item in folders) { string settingFilePath = this.GetSettingFilePhysicalPath(item); CommerceSetting commerceSetting = Serialization.Deserialize <CommerceSetting>(settingFilePath); lst.Add(commerceSetting); } return(lst); }
public ActionResult Create(CommerceSetting setting, string @return) { JsonResultData resultEntry = new JsonResultData(ModelState); try { if (ModelState.IsValid) { this._commerceService.Add(setting); resultEntry.RedirectUrl = Url.Action("Index", "Brand", new { CommerceName = setting.Name }); } } catch (Exception ex) { resultEntry.AddException(ex); } return(Json(resultEntry)); }
public CommerceDbContext Get() { if (this._dbContext != null) { return(this._dbContext); } else { CommerceSetting setting = this._settingProvider.GetByName(AppSetting.CurrentCommerce); string connStr = setting.EnableConnectionString ? setting.ConnectionString : setting.DatabaseFilePath; if (string.IsNullOrEmpty(connStr)) { throw new Exception("Please set up ConnectionString Or DatabaseFilePath for setting.config."); } this._dbContext = new CommerceDbContext(connStr); this._dbContext.Database.CreateIfNotExists(); return(this._dbContext); } }
public void Add(CommerceSetting setting) { string commerceFolder = this.GetCommercePhysicalFolder(setting.Name); if (!Directory.Exists(commerceFolder)) { //Create folder Directory.CreateDirectory(commerceFolder); string imagesFolder = this.GetImageFilePhysicalFolder(setting.Name); string databaseFolder = this.GetDatabaseFilePhysicalFolder(setting.Name); string[] folders = new string[] { imagesFolder, databaseFolder }; foreach (string path in folders) { Directory.CreateDirectory(path); } //Create database if (setting.EnableConnectionString) { CommerceDbContext ctx = new CommerceDbContext(setting.ConnectionString); ctx.Database.Create(); ctx.Dispose(); } else { //SqlCE setting.DatabaseFilePath = this.GetDatabaseFilePhysicalPath(setting.Name); CommerceDbContext ctx = new CommerceDbContext(setting.DatabaseFilePath); ctx.Database.Create(); ctx.Dispose(); } //Create file:setting.config string settingFilePath = this.GetSettingFilePhysicalPath(setting.Name); Serialization.Serialize <CommerceSetting>(setting, settingFilePath); } else { string message = string.Format("{0} is already exist.".Localize()); throw new ArgumentException(message); } }
public void Add(CommerceSetting setting) { this._settingProvider.Add(setting); this.ClearCache(); }
public void Delete(CommerceSetting setting) { throw new NotImplementedException(); }