public CaseVersion MapVersions(CaseTemplatePnDbContext dbContext, Case @case) { CaseVersion caseVersion = new CaseVersion(); caseVersion.Status = @case.Status; caseVersion.Type = @case.Type; caseVersion.CaseTemplate = @case.CaseTemplate; caseVersion.DoneAt = @case.DoneAt; caseVersion.eFormId = @case.eFormId; caseVersion.SiteId = @case.SiteId; caseVersion.UnitId = @case.UnitId; caseVersion.WorkerId = @case.WorkerId; caseVersion.CaseTemplateId = @case.CaseTemplateId; caseVersion.FetchedByTablet = @case.FetchedByTablet; caseVersion.FetchedByTabletAt = @case.FetchedByTabletAt; caseVersion.ReceiptRetrievedFromUser = @case.ReceiptRetrievedFromUser; caseVersion.ReceiptRetrievedFromUserAt = @case.ReceiptRetrievedFromUserAt; caseVersion.Version = @case.Version; caseVersion.CreatedAt = @case.CreatedAt; caseVersion.UpdatedAt = @case.UpdatedAt; caseVersion.WorkflowState = @case.WorkflowState; caseVersion.CaseId = @case.Id; return(caseVersion); }
public void Update(CaseTemplatePnDbContext dbContext) { Case @case = dbContext.Cases.FirstOrDefault(x => x.Id == Id); if (@case == null) { throw new NullReferenceException($"Could not find case with id {Id}"); } @case.Status = Status; @case.Type = Type; @case.CaseTemplate = CaseTemplate; @case.DoneAt = DoneAt; @case.eFormId = eFormId; @case.SiteId = SiteId; @case.UnitId = UnitId; @case.WorkerId = WorkerId; @case.CaseTemplateId = CaseTemplateId; @case.FetchedByTablet = FetchedByTablet; @case.FetchedByTabletAt = FetchedByTabletAt; @case.ReceiptRetrievedFromUser = ReceiptRetrievedFromUser; @case.ReceiptRetrievedFromUserAt = ReceiptRetrievedFromUserAt; if (dbContext.ChangeTracker.HasChanges()) { @case.UpdatedAt = DateTime.Now; @case.Version += 1; dbContext.CaseVersions.Add(MapVersions(dbContext, @case)); dbContext.SaveChanges(); } }
public void Update(CaseTemplatePnDbContext dbContext) { UploadedData uploadedData = dbContext.UploadedDatas.FirstOrDefault(x => x.Id == Id); if (uploadedData == null) { throw new NullReferenceException($"Could not find Uploaded Data with ID {Id}"); } uploadedData.Checksum = Checksum; uploadedData.Extension = Extension; uploadedData.CurrentFile = CurrentFile; uploadedData.UploaderType = UploaderType; uploadedData.FileLocation = FileLocation; uploadedData.FileName = FileName; uploadedData.ExpirationDate = ExpirationDate; uploadedData.Local = Local; uploadedData.OriginalFileName = OriginalFileName; if (dbContext.ChangeTracker.HasChanges()) { uploadedData.UpdatedAt = DateTime.Now; uploadedData.Version += 1; dbContext.UploadedDataVersions.Add(MapVersion(dbContext, uploadedData)); dbContext.SaveChanges(); } }
public UploadedDataVersion MapVersion(CaseTemplatePnDbContext dbContext, UploadedData uploadedData) { UploadedDataVersion uploadedDataVersion = new UploadedDataVersion(); uploadedDataVersion.Checksum = uploadedData.Checksum; uploadedDataVersion.Extension = uploadedData.Extension; uploadedDataVersion.CurrentFile = uploadedData.CurrentFile; uploadedDataVersion.UploaderType = uploadedData.UploaderType; uploadedDataVersion.FileLocation = uploadedData.FileLocation; uploadedDataVersion.FileName = uploadedData.FileName; uploadedDataVersion.ExpirationDate = uploadedData.ExpirationDate; uploadedDataVersion.Local = uploadedData.Local; uploadedDataVersion.OriginalFileName = uploadedData.OriginalFileName; uploadedDataVersion.Version = uploadedData.Version; uploadedDataVersion.CreatedAt = uploadedData.CreatedAt; uploadedDataVersion.UpdatedAt = uploadedData.UpdatedAt; uploadedDataVersion.CreatedByUserId = uploadedData.CreatedByUserId; uploadedDataVersion.UpdatedByUserId = uploadedData.UpdatedByUserId; uploadedDataVersion.WorkflowState = uploadedData.WorkflowState; uploadedDataVersion.UploadedDataId = uploadedData.Id; return(uploadedDataVersion); }
public void Update(CaseTemplatePnDbContext dbContext) { CaseTemplateUploadedData caseTemplateUploadedData = dbContext.CaseTemplateUploadedDatas.FirstOrDefault(x => x.Id == Id); if (caseTemplateUploadedData == null) { throw new NullReferenceException($"Could not find Case Template Uploaded Data with id {Id}"); } caseTemplateUploadedData.Approvable = Approvable; caseTemplateUploadedData.Title = Title; caseTemplateUploadedData.CaseTemplate = CaseTemplate; caseTemplateUploadedData.UploadedData = UploadedData; caseTemplateUploadedData.CaseTemplateId = CaseTemplateId; caseTemplateUploadedData.RetractIfApproved = RetractIfApproved; caseTemplateUploadedData.UploadedDataId = UploadedDataId; if (dbContext.ChangeTracker.HasChanges()) { caseTemplateUploadedData.UpdatedAt = DateTime.Now; caseTemplateUploadedData.Version += 1; dbContext.CaseTemplateUploadedDataVersions.Add(MapVersions(dbContext, caseTemplateUploadedData)); dbContext.SaveChanges(); } }
public void Update(CaseTemplatePnDbContext dbContext) { CaseTemplate caseTemplate = dbContext.CaseTemplates.FirstOrDefault(x => x.Id == Id); if (caseTemplate == null) { throw new NullReferenceException($"Could not find Case Template with id {Id}"); } caseTemplate.Approvable = Approvable; caseTemplate.Body = Body; caseTemplate.Title = Title; caseTemplate.AlwaysShow = AlwaysShow; caseTemplate.EndAt = EndAt; caseTemplate.PdfTitle = PdfTitle; caseTemplate.StartAt = StartAt; caseTemplate.RetractIfApproved = RetractIfApproved; caseTemplate.DescriptionFolderId = DescriptionFolderId; if (dbContext.ChangeTracker.HasChanges()) { caseTemplate.Version += 1; caseTemplate.UpdatedAt = DateTime.Now; dbContext.CaseTemplateVersions.Add(MapVersions(dbContext, caseTemplate)); dbContext.SaveChanges(); } }
private void GetContext(string connectionStr) { CaseTemplatePnContextFactory contextFactory = new CaseTemplatePnContextFactory(); DbContext = contextFactory.CreateDbContext(new[] { connectionStr }); DbContext.Database.Migrate(); DbContext.Database.EnsureCreated(); }
public CaseTemplateService( CaseTemplatePnDbContext dbcontext, IBaneDanmarkLaLocalizationService baneDanmarkLaLocalizationService, IHttpContextAccessor httpContextAccessor, IEFormCoreService core) { _dbContext = dbcontext; _baneDanmarkLaLocalizationService = baneDanmarkLaLocalizationService; _httpContextAccessor = httpContextAccessor; _core = core; }
public void Create(CaseTemplatePnDbContext dbContext) { CreatedAt = DateTime.UtcNow; UpdatedAt = DateTime.UtcNow; Version = 1; WorkflowState = Constants.WorkflowStates.Created; dbContext.CaseTemplateSiteTags.Add(this); dbContext.SaveChanges(); dbContext.CaseTemplateSiteTagVersions.Add(MapVersions(dbContext, this)); dbContext.SaveChanges(); }
public BaneDanmarkLaPnSettingsService(ILogger <BaneDanmarkLaPnSettingsService> logger, IBaneDanmarkLaLocalizationService baneDanmarkLaLocalizationService, CaseTemplatePnDbContext dbContext, IPluginDbOptions <BaneDanmarkLaBaseSettings> options, IHttpContextAccessor httpContextAccessor) { _logger = logger; _dbContext = dbContext; _options = options; _httpContextAccessor = httpContextAccessor; _baneDanmarkLaLocalizationService = baneDanmarkLaLocalizationService; }
public CaseTemplateSiteTagVersion MapVersions(CaseTemplatePnDbContext dbContext, CaseTemplateSiteTag caseTemplateSiteTag) { CaseTemplateSiteTagVersion caseTemplateSiteTagVersion = new CaseTemplateSiteTagVersion(); caseTemplateSiteTagVersion.CaseTemplateId = caseTemplateSiteTag.CaseTemplateId; caseTemplateSiteTagVersion.SdkSiteTagId = caseTemplateSiteTag.SdkSiteTagId; caseTemplateSiteTagVersion.CreatedAt = caseTemplateSiteTag.CreatedAt; caseTemplateSiteTagVersion.UpdatedAt = caseTemplateSiteTag.UpdatedAt; caseTemplateSiteTagVersion.CreatedByUserId = caseTemplateSiteTag.CreatedByUserId; caseTemplateSiteTagVersion.UpdatedByUserId = caseTemplateSiteTag.UpdatedByUserId; caseTemplateSiteTagVersion.Version = caseTemplateSiteTag.Version; caseTemplateSiteTagVersion.WorkflowState = caseTemplateSiteTag.WorkflowState; caseTemplateSiteTagVersion.CaseTemplateSiteTagId = caseTemplateSiteTag.Id; return(caseTemplateSiteTagVersion); }
public DescriptionFolderVersion MapVersions(CaseTemplatePnDbContext dbContext, DescriptionFolder descriptionFolder) { DescriptionFolderVersion descriptionFolderVersion = new DescriptionFolderVersion(); descriptionFolderVersion.Name = descriptionFolder.Name; descriptionFolderVersion.ParentId = descriptionFolder.ParentId; descriptionFolderVersion.SdkFolderId = descriptionFolder.SdkFolderId; descriptionFolderVersion.Version = descriptionFolder.Version; descriptionFolderVersion.CreatedAt = descriptionFolder.CreatedAt; descriptionFolderVersion.UpdatedAt = descriptionFolder.UpdatedAt; descriptionFolderVersion.CreatedByUserId = descriptionFolder.CreatedByUserId; descriptionFolderVersion.UpdatedByUserId = descriptionFolder.UpdatedByUserId; descriptionFolderVersion.WorkflowState = descriptionFolder.WorkflowState; descriptionFolderVersion.DescriptionFolderId = descriptionFolder.Id; return(descriptionFolderVersion); }
public void Delete(CaseTemplatePnDbContext dbContext) { DescriptionFolder descriptionFolder = dbContext.DescriptionFolders.FirstOrDefault(x => x.Id == Id); if (descriptionFolder == null) { throw new NullReferenceException($"Could not find Desxcription Folder with id {Id}"); } descriptionFolder.WorkflowState = Constants.WorkflowStates.Removed; if (dbContext.ChangeTracker.HasChanges()) { descriptionFolder.UpdatedAt = DateTime.Now; descriptionFolder.Version += 1; dbContext.DescriptionFolderVersions.Add(MapVersions(dbContext, this)); dbContext.SaveChanges(); } }
public void Delete(CaseTemplatePnDbContext dbContext) { Case @case = dbContext.Cases.FirstOrDefault(x => x.Id == Id); if (@case == null) { throw new NullReferenceException($"Could not find case with id {Id}"); } @case.WorkflowState = Constants.WorkflowStates.Removed; if (dbContext.ChangeTracker.HasChanges()) { @case.UpdatedAt = DateTime.Now; @case.Version += 1; dbContext.CaseVersions.Add(MapVersions(dbContext, @case)); dbContext.SaveChanges(); } }
public void Delete(CaseTemplatePnDbContext dbContext) { CaseTemplateSiteTag caseTemplateSiteTag = dbContext.CaseTemplateSiteTags.FirstOrDefault(x => x.Id == Id); if (caseTemplateSiteTag == null) { throw new NullReferenceException($"Could not find case template site group with id: {Id}"); } caseTemplateSiteTag.WorkflowState = Constants.WorkflowStates.Removed; if (dbContext.ChangeTracker.HasChanges()) { caseTemplateSiteTag.UpdatedAt = DateTime.Now; caseTemplateSiteTag.Version += 1; dbContext.CaseTemplateSiteTagVersions.Add(MapVersions(dbContext, caseTemplateSiteTag)); dbContext.SaveChanges(); } }
public void Update(CaseTemplatePnDbContext dbContext) { CaseTemplateSite caseTemplateSite = dbContext.CaseTemplateSites.FirstOrDefault(x => x.Id == Id); if (caseTemplateSite == null) { throw new NullReferenceException($"Could not find Case Template Site with id: {Id}"); } caseTemplateSite.CaseTemplateId = CaseTemplateId; caseTemplateSite.SdkSiteId = SdkSiteId; caseTemplateSite.SdkCaseId = SdkCaseId; if (dbContext.ChangeTracker.HasChanges()) { caseTemplateSite.UpdatedAt = DateTime.Now; caseTemplateSite.Version += 1; dbContext.CaseTemplateSiteVersions.Add(MapVersions(dbContext, caseTemplateSite)); dbContext.SaveChanges(); } }
public void Delete(CaseTemplatePnDbContext dbContext) { UploadedData uploadedData = dbContext.UploadedDatas.FirstOrDefault(x => x.Id == Id); if (uploadedData == null) { throw new NullReferenceException($"Could not find Uploaded Data with ID {Id}"); } uploadedData.WorkflowState = Constants.WorkflowStates.Removed; if (dbContext.ChangeTracker.HasChanges()) { uploadedData.UpdatedAt = DateTime.Now; uploadedData.Version += 1; dbContext.UploadedDataVersions.Add(MapVersion(dbContext, uploadedData)); dbContext.SaveChanges(); } }
public CaseTemplateUploadedDataVersion MapVersions(CaseTemplatePnDbContext dbContext, CaseTemplateUploadedData caseTemplateUploadedData) { CaseTemplateUploadedDataVersion caseTemplateUploadedDataVersion = new CaseTemplateUploadedDataVersion(); caseTemplateUploadedDataVersion.Approvable = caseTemplateUploadedData.Approvable; caseTemplateUploadedDataVersion.Title = caseTemplateUploadedData.Title; caseTemplateUploadedDataVersion.CaseTemplate = caseTemplateUploadedData.CaseTemplate; caseTemplateUploadedDataVersion.UploadedData = caseTemplateUploadedData.UploadedData; caseTemplateUploadedDataVersion.CaseTemplateId = caseTemplateUploadedData.CaseTemplateId; caseTemplateUploadedDataVersion.RetractIfApproved = caseTemplateUploadedData.RetractIfApproved; caseTemplateUploadedDataVersion.UploadedDataId = caseTemplateUploadedData.UploadedDataId; caseTemplateUploadedDataVersion.Version = caseTemplateUploadedData.Version; caseTemplateUploadedDataVersion.CreatedAt = caseTemplateUploadedData.CreatedAt; caseTemplateUploadedDataVersion.UpdatedAt = caseTemplateUploadedData.UpdatedAt; caseTemplateUploadedDataVersion.CreatedByUserId = caseTemplateUploadedData.CreatedByUserId; caseTemplateUploadedDataVersion.UpdatedByUserId = caseTemplateUploadedData.UpdatedByUserId; caseTemplateUploadedDataVersion.WorkflowState = caseTemplateUploadedData.WorkflowState; caseTemplateUploadedDataVersion.CaseTemplateUploadedDataId = caseTemplateUploadedData.Id; return(caseTemplateUploadedDataVersion); }
public CaseTemplateVersion MapVersions(CaseTemplatePnDbContext dbContext, CaseTemplate caseTemplate) { CaseTemplateVersion caseTemplateVersion = new CaseTemplateVersion(); caseTemplateVersion.Approvable = caseTemplate.Approvable; caseTemplateVersion.Body = caseTemplate.Body; caseTemplateVersion.Title = caseTemplate.Title; caseTemplateVersion.AlwaysShow = caseTemplate.AlwaysShow; caseTemplateVersion.EndAt = caseTemplate.EndAt; caseTemplateVersion.PdfTitle = caseTemplate.PdfTitle; caseTemplateVersion.StartAt = caseTemplate.StartAt; caseTemplateVersion.RetractIfApproved = caseTemplate.RetractIfApproved; caseTemplateVersion.DescriptionFolderId = caseTemplate.DescriptionFolderId; caseTemplateVersion.Version = caseTemplate.Version; caseTemplateVersion.CreatedAt = caseTemplate.CreatedAt; caseTemplateVersion.UpdatedAt = caseTemplate.UpdatedAt; caseTemplateVersion.WorkflowState = caseTemplate.WorkflowState; caseTemplateVersion.CreatedByUserId = caseTemplate.CreatedByUserId; caseTemplateVersion.UpdatedByUserId = caseTemplate.UpdatedByUserId; caseTemplateVersion.CaseTemplateId = caseTemplate.Id; return(caseTemplateVersion); }
public void Update(CaseTemplatePnDbContext dbContext) { DescriptionFolder descriptionFolder = dbContext.DescriptionFolders.FirstOrDefault(x => x.Id == Id); if (descriptionFolder == null) { throw new NullReferenceException($"Could not find Desxcription Folder with id {Id}"); } descriptionFolder.Name = Name; descriptionFolder.ParentId = ParentId; descriptionFolder.SdkFolderId = SdkFolderId; descriptionFolder.Children = Children; descriptionFolder.Parent = Parent; if (dbContext.ChangeTracker.HasChanges()) { descriptionFolder.UpdatedAt = DateTime.Now; descriptionFolder.Version += 1; dbContext.DescriptionFolderVersions.Add(MapVersions(dbContext, this)); dbContext.SaveChanges(); } }
public static void SeedData(CaseTemplatePnDbContext dbContext) { var seedData = new BaneDanmarkLaConfigurationSeedData(); var configurationList = seedData.Data; foreach (var configurationItem in configurationList) { if (!dbContext.PluginConfigurationValues.Any(x => x.Name == configurationItem.Name)) { var newConfigValue = new PluginConfigurationValue() { Name = configurationItem.Name, Value = configurationItem.Value, CreatedAt = DateTime.UtcNow, UpdatedAt = DateTime.UtcNow, Version = 1, WorkflowState = Constants.WorkflowStates.Created, CreatedByUserId = 1 }; dbContext.PluginConfigurationValues.Add(newConfigValue); dbContext.SaveChanges(); } } }