public async Task <RepositoryResponse <UpdateViewModel> > Save([FromBody] UpdateViewModel model) { if (model != null) { model.CreatedBy = User.Claims.FirstOrDefault(c => c.Type == "Username")?.Value; var result = await base.SaveAsync <UpdateViewModel>(model, true); if (result.IsSucceed) { if (model.Status == MixEnums.MixContentStatus.Schedule) { DateTime dtPublish = DateTime.UtcNow; if (model.PublishedDateTime.HasValue) { dtPublish = model.PublishedDateTime.Value; } MixService.SetConfig(MixConstants.ConfigurationKeyword.NextSyncContent, dtPublish); MixService.Save(); MixService.Reload(); } } return(result); } return(new RepositoryResponse <UpdateViewModel>() { Status = 501 }); }
DateTime?PublishArticles() { var nextSync = MixService.GetConfig <DateTime?>(MixConstants.ConfigurationKeyword.NextSyncContent); if (nextSync.HasValue && nextSync.Value <= DateTime.UtcNow) { var publishedArticles = ReadListItemViewModel.Repository.GetModelListBy( a => a.Status == (int)MixContentStatus.Schedule && (!a.PublishedDateTime.HasValue || a.PublishedDateTime.Value <= DateTime.UtcNow) ); publishedArticles.Data.ForEach(a => a.Status = MixContentStatus.Published); base.SaveList(publishedArticles.Data, false); var next = ReadListItemViewModel.Repository.Min(a => a.Type == (int)MixContentStatus.Schedule, a => a.PublishedDateTime); nextSync = next.Data; MixService.SetConfig(MixConstants.ConfigurationKeyword.NextSyncContent, nextSync); MixService.Save(); MixService.Reload(); return(nextSync); } else { return(nextSync); } }
public override async Task <RepositoryResponse <UpdateViewModel> > SaveModelAsync(bool isSaveSubModels = false, MixCmsContext _context = null, IDbContextTransaction _transaction = null) { var result = await base.SaveModelAsync(isSaveSubModels, _context, _transaction); if (result.IsSucceed) { MixService.LoadFromDatabase(); MixService.Save(); } return(result); }
public async Task <RepositoryResponse <UpdateViewModel> > Save([FromBody] UpdateViewModel model) { var result = await base.SaveAsync <UpdateViewModel>(model, true); if (result.IsSucceed) { MixService.LoadFromDatabase(); MixService.Save(); } return(result); }
public override async Task <RepositoryResponse <MixLanguage> > RemoveModelAsync(bool isRemoveRelatedModels = false, MixCmsContext _context = null, IDbContextTransaction _transaction = null) { var result = await base.RemoveModelAsync(isRemoveRelatedModels, _context, _transaction); if (result.IsSucceed) { if (result.IsSucceed) { MixService.LoadFromDatabase(); MixService.Save(); } } 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) { MixService.LoadFromDatabase(); MixService.Save(); } return(result); } return(new RepositoryResponse <UpdateViewModel>() { Status = 501 }); }
private async Task <RepositoryResponse <bool> > InitCmsAsync(InitCmsViewModel model) { var result = new RepositoryResponse <bool>(); MixService.SetConnectionString(MixConstants.CONST_CMS_CONNECTION, model.ConnectionString); MixService.SetConnectionString(MixConstants.CONST_MESSENGER_CONNECTION, model.ConnectionString); MixService.SetConnectionString(MixConstants.CONST_ACCOUNT_CONNECTION, model.ConnectionString); MixService.SetConfig(MixConstants.CONST_SETTING_IS_SQLITE, model.IsSqlite); MixService.SetConfig(MixConstants.CONST_SETTING_LANGUAGE, model.Culture.Specificulture); InitCmsService sv = new InitCmsService(); var initResult = await sv.InitCms(model.Culture); if (initResult.IsSucceed) { await InitRolesAsync(); result.IsSucceed = true; MixService.LoadFromDatabase(); MixService.SetConfig <bool>("IsInit", true); MixService.SetConfig <string>("DefaultCulture", model.Culture.Specificulture); MixService.Save(); MixService.Reload(); } else { MixService.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); }