public override bool Execute(KitosContext context) { var commonOrg = context.GetOrganization(TestOrganizations.CommonOrg); var globalAdmin = context.GetGlobalAdmin(); var existing = context.Reports.AsNoTracking().FirstOrDefault(x => x.Name == _name); if (existing != null) { Console.Out.WriteLine($"Existing Report with name {_name} already exists in the database."); return(false); } var entity = new Report() { Name = _name, ObjectOwnerId = globalAdmin.Id, OrganizationId = commonOrg.Id, LastChangedByUserId = globalAdmin.Id, Description = "Test rapport oprettet til accessibility tests" }; context.Reports.Add(entity); context.SaveChanges(); return(true); }
public override bool Execute(KitosContext context) { var commonOrg = context.GetOrganization(TestOrganizations.CommonOrg); var globalAdmin = context.GetGlobalAdmin(); var projectWithName = context.ItProjects.AsNoTracking().FirstOrDefault(x => x.Name == _name); if (projectWithName != null) { Console.Out.WriteLine($"Existing ItProject with name {_name} already exists in the database."); return(false); } var project = ItProjectFactory.Create(_name, commonOrg.Id); var entities = new List <IEntity>(); entities.Add(project); entities.Add(project.GoalStatus); entities.Add(project.Handover); entities.AddRange(project.EconomyYears); entities.ForEach(entity => { entity.ObjectOwner = globalAdmin; entity.LastChangedByUser = globalAdmin; entity.LastChanged = DateTime.Now; }); context.ItProjects.Add(project); context.SaveChanges(); return(true); }
public override bool Execute(KitosContext context) { var commonOrg = context.GetOrganization(TestOrganizations.CommonOrg); var globalAdmin = context.GetGlobalAdmin(); var systemWithSameName = context.ItContracts.AsNoTracking().FirstOrDefault(x => x.Name == _name); if (systemWithSameName != null) { Console.Out.WriteLine($"Existing ItContract with name {_name} already exists in the database."); return(false); } var itContract = new ItContract { Name = _name, ObjectOwnerId = globalAdmin.Id, OrganizationId = commonOrg.Id, LastChangedByUserId = globalAdmin.Id, }; context.ItContracts.Add(itContract); context.SaveChanges(); return(true); }
public override bool Execute(KitosContext context) { var organization = context.GetOrganization(_organizationName); var globalAdmin = context.GetGlobalAdmin(); //Create the new it system var systemWithSameName = GetItSystemnByName(context); if (systemWithSameName != null) { Console.Out.WriteLine($"Existing ITSystem with name {_name} already exists in the database."); return(false); } var itSystem = new ItSystem { Name = _name, ObjectOwnerId = globalAdmin.Id, OrganizationId = organization.Id, LastChangedByUserId = globalAdmin.Id, Uuid = Guid.NewGuid(), ParentId = _parentId }; context.ItSystems.Add(itSystem); context.SaveChanges(); //Enable usage of the system var itSystemUsage = new ItSystemUsage { ItSystemId = itSystem.Id, OrganizationId = organization.Id, ObjectOwnerId = globalAdmin.Id, LastChangedByUserId = globalAdmin.Id }; itSystemUsage.ResponsibleUsage = new ItSystemUsageOrgUnitUsage { ItSystemUsage = itSystemUsage, ItSystemUsageId = itSystemUsage.Id, OrganizationUnit = organization.OrgUnits.First(), OrganizationUnitId = organization.Id }; context.ItSystemUsages.Add(itSystemUsage); context.SaveChanges(); var pendingReadModelUpdate = PendingReadModelUpdate.Create(itSystemUsage, PendingReadModelUpdateSourceCategory.ItSystemUsage); context.PendingReadModelUpdates.Add(pendingReadModelUpdate); context.SaveChanges(); return(true); }
private void AssignOrganizationRole(KitosContext context, User newUser, string orgName) { var globalAdmin = context.GetGlobalAdmin(); var org = context.GetOrganization(orgName); var newRight = new OrganizationRight { UserId = newUser.Id, Role = _role, OrganizationId = org.Id, ObjectOwnerId = globalAdmin.Id, LastChangedByUserId = globalAdmin.Id }; context.OrganizationRights.Add(newRight); context.SaveChanges(); }
public override bool Execute(KitosContext dbContext) { var commonOrg = dbContext.GetOrganization(TestOrganizations.CommonOrg); var globalAdmin = dbContext.GetGlobalAdmin(); var agreement = new DataProcessingRegistration() { Name = _name, ObjectOwnerId = globalAdmin.Id, OrganizationId = commonOrg.Id, LastChangedByUserId = globalAdmin.Id }; agreement = dbContext.DataProcessingRegistrations.Add(agreement); dbContext.SaveChanges(); var readModel = new DataProcessingRegistrationReadModel(); var update = new DataProcessingRegistrationReadModelUpdate( new GenericRepository <DataProcessingRegistrationRoleAssignmentReadModel>(dbContext), new OptionsService <DataProcessingRegistration, DataProcessingBasisForTransferOption, LocalDataProcessingBasisForTransferOption> ( new GenericRepository <LocalDataProcessingBasisForTransferOption>(dbContext), new GenericRepository <DataProcessingBasisForTransferOption>(dbContext) ), new OptionsService <DataProcessingRegistration, DataProcessingDataResponsibleOption, LocalDataProcessingDataResponsibleOption> ( new GenericRepository <LocalDataProcessingDataResponsibleOption>(dbContext), new GenericRepository <DataProcessingDataResponsibleOption>(dbContext) ), new OptionsService <DataProcessingRegistration, DataProcessingOversightOption, LocalDataProcessingOversightOption> ( new GenericRepository <LocalDataProcessingOversightOption>(dbContext), new GenericRepository <DataProcessingOversightOption>(dbContext) ) ); update.Apply(agreement, readModel); dbContext.DataProcessingRegistrationReadModels.Add(readModel); dbContext.SaveChanges(); return(true); }
public override bool Execute(KitosContext context) { var organization = context.GetOrganization(_organizationName); var globalAdmin = context.GetGlobalAdmin(); var taskRef = new TaskRef() { Uuid = new Guid(), Type = "TestKLEType", TaskKey = "TestKLEKey", Description = "Test task ref", OwnedByOrganizationUnitId = organization.Id, ObjectOwnerId = globalAdmin.Id, LastChanged = DateTime.Now, LastChangedByUserId = globalAdmin.Id }; context.TaskRefs.Add(taskRef); context.SaveChanges(); return(true); }