public override async Task <RepositoryResponse <UpdateViewModel> > SaveModelAsync(bool isSaveSubModels = false, SioCmsContext _context = null, IDbContextTransaction _transaction = null) { var result = await base.SaveModelAsync(isSaveSubModels, _context, _transaction); if (result.IsSucceed) { SioService.LoadFromDatabase(); SioService.SaveSettings(); } return(result); }
public async Task <RepositoryResponse <UpdateViewModel> > Save([FromBody] UpdateViewModel model) { var result = await base.SaveAsync <UpdateViewModel>(model, true); if (result.IsSucceed) { SioService.LoadFromDatabase(); SioService.Save(); } return(result); }
public async Task <RepositoryResponse <UpdateViewModel> > Save([FromBody] UpdateViewModel model) { var result = await base.SaveAsync <UpdateViewModel>(model, true); if (result.IsSucceed) { SioService.SetConfig("LastUpdateConfiguration", DateTime.UtcNow); SioService.LoadFromDatabase(); SioService.SaveSettings(); } return(result); }
public override async Task <RepositoryResponse <SioLanguage> > RemoveModelAsync(bool isRemoveRelatedModels = false, SioCmsContext _context = null, IDbContextTransaction _transaction = null) { var result = await base.RemoveModelAsync(isRemoveRelatedModels, _context, _transaction); if (result.IsSucceed) { if (result.IsSucceed) { SioService.LoadFromDatabase(); SioService.SaveSettings(); } } return(result); }
private async Task <RepositoryResponse <bool> > InitCmsAsync(InitCmsViewModel model) { var result = new RepositoryResponse <bool>(); SioService.SetConnectionString(SioConstants.CONST_CMS_CONNECTION, model.ConnectionString); SioService.SetConnectionString(SioConstants.CONST_MESSENGER_CONNECTION, model.ConnectionString); SioService.SetConnectionString(SioConstants.CONST_ACCOUNT_CONNECTION, model.ConnectionString); SioService.SetConfig(SioConstants.CONST_SETTING_IS_MYSQL, model.IsMysql); SioService.SetConfig(SioConstants.CONST_SETTING_DATABASE_PROVIDER, model.DatabaseProvider); SioService.SetConfig(SioConstants.CONST_SETTING_LANGUAGE, model.Culture.Specificulture); InitCmsService sv = new InitCmsService(); var initResult = await sv.InitCms(model.SiteName, model.Culture); if (initResult.IsSucceed) { await InitRolesAsync(); result.IsSucceed = true; SioService.LoadFromDatabase(); SioService.SetConfig <bool>("IsInit", true); SioService.SetConfig <string>("DefaultCulture", model.Culture.Specificulture); SioService.SaveSettings(); SioService.Reload(); } else { // if cannot init cms // => reload from default settings // => save to appSettings SioService.Reload(); SioService.SaveSettings(); if (initResult.Exception != null) { result.Errors.Add(initResult.Exception.Message); result.Exception = initResult.Exception; } foreach (var item in initResult.Errors) { result.Errors.Add(item); } } return(result); }
public async Task <RepositoryResponse <UpdateViewModel> > Save([FromBody] UpdateViewModel model) { if (model != null) { model.CreatedBy = User.Claims.FirstOrDefault(c => c.Type == "Username")?.Value; model.Specificulture = _lang; var result = await base.SaveAsync <UpdateViewModel>(model, true); if (result.IsSucceed) { SioService.LoadFromDatabase(); SioService.Save(); } return(result); } return(new RepositoryResponse <UpdateViewModel>() { Status = 501 }); }
private async Task <RepositoryResponse <bool> > InitCmsAsync(InitCmsViewModel model) { var result = new RepositoryResponse <bool>(); SioService.SetConnectionString(SioConstants.CONST_CMS_CONNECTION, model.ConnectionString); SioService.SetConnectionString(SioConstants.CONST_MESSENGER_CONNECTION, model.ConnectionString); SioService.SetConnectionString(SioConstants.CONST_ACCOUNT_CONNECTION, model.ConnectionString); SioService.SetConfig(SioConstants.CONST_SETTING_IS_SQLITE, model.IsSqlite); SioService.SetConfig(SioConstants.CONST_SETTING_LANGUAGE, model.Culture.Specificulture); InitCmsService sv = new InitCmsService(); var initResult = await sv.InitCms(model.SiteName, model.Culture); if (initResult.IsSucceed) { await InitRolesAsync(); result.IsSucceed = true; SioService.LoadFromDatabase(); SioService.SetConfig <bool>("IsInit", true); SioService.SetConfig <string>("DefaultCulture", model.Culture.Specificulture); SioService.Save(); SioService.Reload(); } else { SioService.Reload(); if (initResult.Exception != null) { result.Errors.Add(initResult.Exception.Message); result.Exception = initResult.Exception; } foreach (var item in initResult.Errors) { result.Errors.Add(item); } } return(result); }
public async Task <RepositoryResponse <UpdateViewModel> > Save([FromForm] string model, [FromForm] IFormFile assets, [FromForm] IFormFile theme) { var json = JObject.Parse(model); var data = json.ToObject <UpdateViewModel>(); if (assets != null) { data.Asset = new Lib.ViewModels.FileViewModel(assets, data.AssetFolder); FileRepository.Instance.SaveWebFile(assets, data.AssetFolder); } if (theme != null) { string importFolder = $"Imports/Themes/{DateTime.UtcNow.ToShortDateString()}/{data.Name}"; data.TemplateAsset = new Lib.ViewModels.FileViewModel(theme, importFolder); FileRepository.Instance.SaveWebFile(theme, importFolder); } if (data != null) { data.CreatedBy = User.Claims.FirstOrDefault(c => c.Type == "Username")?.Value; data.Specificulture = _lang; var result = await base.SaveAsync <UpdateViewModel>(data, true); if (result.IsSucceed) { SioService.LoadFromDatabase(); SioService.SaveSettings(); } return(result); } return(new RepositoryResponse <UpdateViewModel>() { Status = 501 }); }