Refactor code structure for improved readability and maintainability

This commit is contained in:
Torsten Brendgen
2026-07-07 23:27:57 +02:00
parent 96a3e98109
commit bbe521b38d
1632 changed files with 27313 additions and 54917 deletions
-70
View File
@@ -1,70 +0,0 @@
using System.Net.Http.Headers;
using System.Text;
using System.Text.Json;
namespace Microsoft.SelfService.Portal.Core.API.Helper
{
public class APIHelper
{
public static HttpClient ApiClient { get; set; } = new HttpClient();
public static String _Url;
public static String _Body;
public APIHelper()
{
ApiClient = new HttpClient();
ApiClient.BaseAddress = new Uri("http://rz1vcmsma001.cm.p01s01.ccis.svc.intranetbw.de:8080");
ApiClient.DefaultRequestHeaders.Accept.Clear();
ApiClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/xml"));
ApiClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", Convert.ToBase64String(
Encoding.UTF8.GetBytes("CCIS-P01S01-CM\\ASA_Administrator:UQp7AurAkH4M")
));
}
public static void SetUrl(Guid RunbookId, String RestEndpointMethod)
{
_Url = string.Format("/00000000-0000-0000-0000-000000000000/Runbooks(guid'{0}')/{1}", RunbookId, RestEndpointMethod);
}
public static string GetUrl()
{
return _Url;
}
public static StringContent SetRequestHeaders(String ContentType)
{
MediaTypeHeaderValue JsonMediaType = null;
MediaTypeHeaderValue.TryParse(ContentType, out JsonMediaType);
return new StringContent(_Body, Encoding.UTF8, JsonMediaType); ;
}
public static void SetRequestBody(Guid parameters)
{
var obj = new
{
parameters = new[]
{
new
{
__metadata = new
{
type = "Orchestrator.ResourceModel.NameValuePair"
},
Name = "deploymentId",
Value = parameters
}
}
};
_Body = JsonSerializer.Serialize(obj);
}
public static String GetRequestBody()
{
return _Body;
}
}
}
+55 -36
View File
@@ -3,23 +3,26 @@ using Microsoft.SelfService.Portal.Core.API.Models;
using Microsoft.SelfService.Portal.Core.API.Dto;
using Microsoft.SelfService.Portal.Core.API.Dto.Domain.Get;
using Microsoft.SelfService.Portal.Core.API.Dto.Domain.Add;
using Microsoft.SelfService.Portal.Core.API.Dto.Runbook.Get;
using Microsoft.SelfService.Portal.Core.API.Dto.Runbook.Add;
using Microsoft.SelfService.Portal.Core.API.Dto.Environment.Get;
using Microsoft.SelfService.Portal.Core.API.Dto.VirtualMachine.Get;
using Microsoft.SelfService.Portal.Core.API.Dto.VirtualMachine.Add;
using Microsoft.SelfService.Portal.Core.API.Dto.VirtualMachine.Edit;
using Microsoft.SelfService.Portal.Core.API.Dto.Target.Get;
using Microsoft.SelfService.Portal.Core.API.Dto.Target.Add;
using Microsoft.SelfService.Portal.Core.API.Dto.Target.Edit;
using Microsoft.SelfService.Portal.Core.API.Dto.Domain.Edit;
using Microsoft.SelfService.Portal.Core.API.Dto.Environment.Add;
using Microsoft.SelfService.Portal.Core.API.Dto.Environment.Edit;
using Microsoft.SelfService.Portal.Core.API.Dto.Deployment.Get;
using Microsoft.SelfService.Portal.Core.API.Dto.Deployment.Add;
using Microsoft.SelfService.Portal.Core.API.Dto.Deployment.Edit;
using Microsoft.SelfService.Portal.Core.API.Dto.DeploymentGroup.Get;
using Microsoft.SelfService.Portal.Core.API.Dto.DeploymentGroup.Add;
using Microsoft.SelfService.Portal.Core.API.Dto.DeploymentBatch.Get;
using Microsoft.SelfService.Portal.Core.API.Dto.DeploymentBatch.Add;
using Microsoft.SelfService.Portal.Core.API.Dto.DeploymentBatch.Edit;
using Microsoft.SelfService.Portal.Core.API.Dto.DeploymentComposition.Add;
using Microsoft.SelfService.Portal.Core.API.Dto.DeploymentComposition.Get;
using Microsoft.SelfService.Portal.Core.API.Dto.Template.Get;
using Microsoft.SelfService.Portal.Core.API.Dto.Template.Add;
using Microsoft.SelfService.Portal.Core.API.Dto.Template.Edit;
using Microsoft.SelfService.Portal.Core.API.Dto.TemplateVersion.Add;
using Microsoft.SelfService.Portal.Core.API.Dto.TemplateVersion.Get;
using Microsoft.SelfService.Portal.Core.API.Dto.Service.Get;
using Microsoft.SelfService.Portal.Core.API.Dto.Service.Add;
using Microsoft.SelfService.Portal.Core.API.Dto.Service.Edit;
@@ -40,8 +43,8 @@ namespace Microsoft.SelfService.Portal.Core.API.Helper
CreateMap<GetDomainDetailsDto, DomainModel>();
CreateMap<DomainModel, GetDomainEnvironmentDto>();
CreateMap<GetDomainEnvironmentDto, DomainModel>();
CreateMap<DomainModel, GetDomainVirtualMachineDetailsDto>();
CreateMap<GetDomainVirtualMachineDetailsDto, DomainModel>();
CreateMap<DomainModel, GetDomainTargetDetailsDto>();
CreateMap<GetDomainTargetDetailsDto, DomainModel>();
CreateMap<DomainModel, AddDomainDto>();
CreateMap<AddDomainDto, DomainModel>();
CreateMap<DomainModel, EditDomainDto>();
@@ -67,41 +70,50 @@ namespace Microsoft.SelfService.Portal.Core.API.Helper
CreateMap<EnvironmentDomainsModel, AddEnvironmentDomainDto>();
CreateMap<AddEnvironmentDomainDto, EnvironmentDomainsModel>();
/** Virtual Machine Model **/
CreateMap<VirtualMachineModel, GetVirtualMachineDto>();
CreateMap<GetVirtualMachineDto, VirtualMachineModel>();
CreateMap<VirtualMachineModel, GetVirtualMachineDetailsDto>();
CreateMap<GetVirtualMachineDetailsDto, VirtualMachineModel>();
CreateMap<VirtualMachineModel, AddVirtualMachineDto>();
CreateMap<AddVirtualMachineDto, VirtualMachineModel>();
CreateMap<VirtualMachineModel, EditVirtualMachineDto>();
CreateMap<EditVirtualMachineDto, VirtualMachineModel>();
/** Runbook Model **/
CreateMap<RunbookModel, GetRunbookDto>();
CreateMap<GetRunbookDto, RunbookModel>();
CreateMap<RunbookModel, GetRunbookDetailsDto>();
CreateMap<GetRunbookDetailsDto, RunbookModel>();
CreateMap<RunbookModel, AddRunbookDto>();
CreateMap<AddRunbookDto, RunbookModel>();
/** Target Model **/
CreateMap<TargetModel, GetTargetDto>();
CreateMap<GetTargetDto, TargetModel>();
CreateMap<TargetModel, GetTargetDetailsDto>();
CreateMap<GetTargetDetailsDto, TargetModel>();
CreateMap<TargetModel, AddTargetDto>();
CreateMap<AddTargetDto, TargetModel>();
CreateMap<TargetModel, EditTargetDto>();
CreateMap<EditTargetDto, TargetModel>();
/** Deployment Model **/
CreateMap<DeploymentModel, GetDeploymentDto>();
CreateMap<GetDeploymentDto, DeploymentModel>();
CreateMap<DeploymentModel, GetDeploymentDetailsDto>();
CreateMap<GetDeploymentDetailsDto, DeploymentModel>();
CreateMap<DeploymentModel, AddDeploymentDto>();
CreateMap<AddDeploymentDto, DeploymentModel>();
CreateMap<DeploymentModel, EditDeploymentDto>();
CreateMap<EditDeploymentDto, DeploymentModel>();
CreateMap<DeploymentModel, AddDeploymentDto>()
.ForMember(destination => destination.JsonData, option => option.MapFrom(source => source.JSONData));
CreateMap<AddDeploymentDto, DeploymentModel>()
.ForMember(destination => destination.JSONData, option => option.MapFrom(source => source.JsonData));
CreateMap<DeploymentModel, EditDeploymentDto>()
.ForMember(destination => destination.jsonData, option => option.MapFrom(source => source.JSONData));
CreateMap<EditDeploymentDto, DeploymentModel>()
.ForMember(destination => destination.JSONData, option => option.MapFrom(source => source.jsonData));
/** Deployment Group Model **/
CreateMap<DeploymentGroupModel, GetDeploymentGroupDto>();
CreateMap<GetDeploymentGroupDto, DeploymentGroupModel>();
CreateMap<DeploymentGroupModel, GetDeploymentGroupDetailsDto>();
CreateMap<GetDeploymentGroupDetailsDto, DeploymentGroupModel>();
CreateMap<DeploymentGroupModel, AddDeploymentGroupDto>();
CreateMap<AddDeploymentGroupDto, DeploymentGroupModel>();
CreateMap<DeploymentGroupModel, GetDeploymentBatchDto>();
CreateMap<GetDeploymentBatchDto, DeploymentGroupModel>();
CreateMap<DeploymentGroupModel, GetDeploymentBatchDetailsDto>();
CreateMap<GetDeploymentBatchDetailsDto, DeploymentGroupModel>();
CreateMap<DeploymentGroupModel, AddDeploymentBatchDto>();
CreateMap<AddDeploymentBatchDto, DeploymentGroupModel>();
CreateMap<DeploymentGroupModel, EditDeploymentBatchDto>();
CreateMap<EditDeploymentBatchDto, DeploymentGroupModel>();
/** Deployment Composition Model **/
CreateMap<DeploymentTemplateSelectionModel, GetDeploymentTemplateSelectionDto>();
CreateMap<GetDeploymentTemplateSelectionDto, DeploymentTemplateSelectionModel>();
CreateMap<AddDeploymentTemplateSelectionDto, DeploymentTemplateSelectionModel>();
CreateMap<DeploymentParameterValueModel, GetDeploymentParameterValueDto>();
CreateMap<GetDeploymentParameterValueDto, DeploymentParameterValueModel>();
CreateMap<AddDeploymentParameterValueDto, DeploymentParameterValueModel>();
CreateMap<DeploymentTargetAssignmentModel, GetDeploymentTargetAssignmentDto>();
CreateMap<GetDeploymentTargetAssignmentDto, DeploymentTargetAssignmentModel>();
CreateMap<AddDeploymentTargetAssignmentDto, DeploymentTargetAssignmentModel>();
/** Template Model **/
CreateMap<TemplateModel, GetTemplateDto>();
@@ -113,6 +125,12 @@ namespace Microsoft.SelfService.Portal.Core.API.Helper
CreateMap<TemplateModel, EditTemplateDto>();
CreateMap<EditTemplateDto, TemplateModel>();
/** Template Version Model **/
CreateMap<TemplateVersionModel, GetTemplateVersionDto>();
CreateMap<GetTemplateVersionDto, TemplateVersionModel>();
CreateMap<TemplateVersionModel, AddTemplateVersionDto>();
CreateMap<AddTemplateVersionDto, TemplateVersionModel>();
/** Service Model **/
CreateMap<ServiceModel, GetServiceDto>();
CreateMap<GetServiceDto, ServiceModel>();
@@ -135,3 +153,4 @@ namespace Microsoft.SelfService.Portal.Core.API.Helper
}
}
}