Skip to content

Commit 1fc344e

Browse files
fixes from deepsource
1 parent 1924402 commit 1fc344e

File tree

4 files changed

+131
-173
lines changed

4 files changed

+131
-173
lines changed

MobileConfiguration/Database/Migrations/SqlServer/ConfigurationSqlServerContextModelSnapshot.cs

Lines changed: 22 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -10,69 +10,46 @@
1010
namespace MobileConfiguration.Database.Migrations.SqlServer;
1111

1212
[DbContext(typeof(ConfigurationContext))]
13-
partial class ConfigurationSqlServerContextModelSnapshot : ModelSnapshot
14-
{
15-
protected override void BuildModel(ModelBuilder modelBuilder)
16-
{
13+
partial class ConfigurationSqlServerContextModelSnapshot : ModelSnapshot {
14+
protected override void BuildModel(ModelBuilder modelBuilder) {
1715
#pragma warning disable 612, 618
18-
modelBuilder
19-
.HasAnnotation("ProductVersion", "9.0.5")
20-
.HasAnnotation("Relational:MaxIdentifierLength", 128);
16+
modelBuilder.HasAnnotation("ProductVersion", "9.0.5").HasAnnotation("Relational:MaxIdentifierLength", 128);
2117

2218
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
2319

24-
modelBuilder.Entity("MobileConfiguration.Database.Entities.Configuration", b =>
25-
{
26-
b.Property<string>("Id")
27-
.HasColumnType("nvarchar(450)");
20+
modelBuilder.Entity("MobileConfiguration.Database.Entities.Configuration", b => {
21+
b.Property<string>("Id").HasColumnType("nvarchar(450)");
2822

29-
b.Property<int>("ConfigType")
30-
.HasColumnType("int");
23+
b.Property<int>("ConfigType").HasColumnType("int");
3124

32-
b.Property<string>("ClientId")
33-
.IsRequired()
34-
.HasColumnType("nvarchar(max)");
25+
b.Property<string>("ClientId").IsRequired().HasColumnType("nvarchar(max)");
3526

36-
b.Property<string>("ClientSecret")
37-
.IsRequired()
38-
.HasColumnType("nvarchar(max)");
27+
b.Property<string>("ClientSecret").IsRequired().HasColumnType("nvarchar(max)");
3928

40-
b.Property<string>("DeviceIdentifier")
41-
.IsRequired()
42-
.HasColumnType("nvarchar(max)");
29+
b.Property<string>("DeviceIdentifier").IsRequired().HasColumnType("nvarchar(max)");
4330

44-
b.Property<bool>("EnableAutoUpdates")
45-
.HasColumnType("bit");
31+
b.Property<bool>("EnableAutoUpdates").HasColumnType("bit");
4632

47-
b.Property<string>("HostAddresses")
48-
.IsRequired()
49-
.HasColumnType("nvarchar(max)");
33+
b.Property<string>("HostAddresses").IsRequired().HasColumnType("nvarchar(max)");
5034

51-
b.Property<int>("LogLevelId")
52-
.HasColumnType("int");
35+
b.Property<int>("LogLevelId").HasColumnType("int");
5336

54-
b.HasKey("Id", "ConfigType");
37+
b.HasKey("Id", "ConfigType");
5538

56-
b.ToTable("Configurations");
57-
});
39+
b.ToTable("Configurations");
40+
});
5841

59-
modelBuilder.Entity("MobileConfiguration.Database.Entities.LoggingLevels", b =>
60-
{
61-
b.Property<int>("LogLevelId")
62-
.ValueGeneratedOnAdd()
63-
.HasColumnType("int");
42+
modelBuilder.Entity("MobileConfiguration.Database.Entities.LoggingLevels", b => {
43+
b.Property<int>("LogLevelId").ValueGeneratedOnAdd().HasColumnType("int");
6444

65-
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("LogLevelId"));
45+
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("LogLevelId"));
6646

67-
b.Property<string>("Description")
68-
.IsRequired()
69-
.HasColumnType("nvarchar(max)");
47+
b.Property<string>("Description").IsRequired().HasColumnType("nvarchar(max)");
7048

71-
b.HasKey("LogLevelId");
49+
b.HasKey("LogLevelId");
7250

73-
b.ToTable("LoggingLevels");
74-
});
51+
b.ToTable("LoggingLevels");
52+
});
7553
#pragma warning restore 612, 618
76-
}
7754
}
7855
}

MobileConfiguration/Factories/Factory.cs

Lines changed: 45 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,9 @@
77

88
namespace MobileConfiguration.Factories;
99

10-
public static class Factory
11-
{
10+
public static class Factory {
1211
public static Models.MobileConfiguration ToMobileConfiguration(Configuration configuration) {
13-
Models.MobileConfiguration configurationModel = new()
14-
{
12+
Models.MobileConfiguration configurationModel = new() {
1513
ClientId = configuration.ClientId,
1614
ClientSecret = configuration.ClientSecret,
1715
ConfigurationType = ConfigurationType.TransactionMobile,
@@ -21,12 +19,10 @@ public static Models.MobileConfiguration ToMobileConfiguration(Configuration con
2119
HostAddresses = new List<Models.HostAddress>()
2220
};
2321

24-
foreach (HostAddress configurationHostAddress in configuration.HostAddresses)
25-
{
26-
Models.HostAddress hostAddressModel = new()
27-
{
28-
Uri = configurationHostAddress.Uri, ServiceType = configurationHostAddress.ServiceType switch
29-
{
22+
foreach (HostAddress configurationHostAddress in configuration.HostAddresses) {
23+
Models.HostAddress hostAddressModel = new() {
24+
Uri = configurationHostAddress.Uri,
25+
ServiceType = configurationHostAddress.ServiceType switch {
3026
ServiceType.EstateManagement => Models.ServiceType.EstateManagement,
3127
ServiceType.TransactionProcessorAcl => Models.ServiceType.TransactionProcessorAcl,
3228
ServiceType.VoucherManagementAcl => Models.ServiceType.VoucherManagementAcl,
@@ -37,8 +33,7 @@ public static Models.MobileConfiguration ToMobileConfiguration(Configuration con
3733
configurationModel.HostAddresses.Add(hostAddressModel);
3834
}
3935

40-
configurationModel.LogLevel = configuration.LogLevel switch
41-
{
36+
configurationModel.LogLevel = configuration.LogLevel switch {
4237
LoggingLevel.Debug => Models.LoggingLevel.Debug,
4338
LoggingLevel.Error => Models.LoggingLevel.Error,
4439
LoggingLevel.Fatal => Models.LoggingLevel.Fatal,
@@ -52,59 +47,50 @@ public static Models.MobileConfiguration ToMobileConfiguration(Configuration con
5247
}
5348

5449
public static Database.Entities.Configuration ToEntityConfiguration(Models.MobileConfiguration configurationModel) {
55-
Database.Entities.Configuration configurationEntity = new()
56-
{
50+
Database.Entities.Configuration configurationEntity = new() {
5751
Id = configurationModel.Id,
5852
ConfigType = (Int32)ConfigurationType.TransactionMobile,
59-
ClientId = configurationModel.ClientId,
60-
ClientSecret = configurationModel.ClientSecret,
61-
DeviceIdentifier = configurationModel.DeviceIdentifier,
62-
EnableAutoUpdates = configurationModel.EnableAutoUpdates,
63-
LogLevelId = (Int32)configurationModel.LogLevel,
64-
HostAddresses = JsonConvert.SerializeObject(configurationModel.HostAddresses)
65-
};
66-
67-
return configurationEntity;
68-
}
69-
70-
public static ConfigurationResponse ToConfigurationResponse(Models.MobileConfiguration configurationModel) {
71-
ConfigurationResponse response = new ConfigurationResponse
72-
{
73-
HostAddresses = new List<HostAddress>(),
74-
Id = configurationModel.Id,
75-
ClientSecret = configurationModel.ClientSecret,
76-
DeviceIdentifier = configurationModel.DeviceIdentifier,
77-
EnableAutoUpdates = configurationModel.EnableAutoUpdates,
78-
ClientId = configurationModel.ClientId,
79-
};
53+
ClientId = configurationModel.ClientId,
54+
ClientSecret = configurationModel.ClientSecret,
55+
DeviceIdentifier = configurationModel.DeviceIdentifier,
56+
EnableAutoUpdates = configurationModel.EnableAutoUpdates,
57+
LogLevelId = (Int32)configurationModel.LogLevel,
58+
HostAddresses = JsonConvert.SerializeObject(configurationModel.HostAddresses)
59+
};
8060

81-
foreach (Models.HostAddress configurationHostAddress in configurationModel.HostAddresses)
82-
{
83-
HostAddress hostAddress = new HostAddress
84-
{
85-
Uri = configurationHostAddress.Uri,
86-
};
87-
hostAddress.ServiceType = configurationHostAddress.ServiceType switch
88-
{
89-
Models.ServiceType.TransactionProcessorAcl => ServiceType.TransactionProcessorAcl,
90-
_ => ServiceType.Security
91-
};
61+
return configurationEntity;
62+
}
9263

93-
response.HostAddresses.Add(hostAddress);
94-
}
64+
public static ConfigurationResponse ToConfigurationResponse(Models.MobileConfiguration configurationModel) {
65+
ConfigurationResponse response = new ConfigurationResponse {
66+
HostAddresses = new List<HostAddress>(),
67+
Id = configurationModel.Id,
68+
ClientSecret = configurationModel.ClientSecret,
69+
DeviceIdentifier = configurationModel.DeviceIdentifier,
70+
EnableAutoUpdates = configurationModel.EnableAutoUpdates,
71+
ClientId = configurationModel.ClientId,
72+
};
9573

96-
response.LogLevel = configurationModel.LogLevel switch
97-
{
98-
Models.LoggingLevel.Debug => LoggingLevel.Debug,
99-
Models.LoggingLevel.Error => LoggingLevel.Error,
100-
Models.LoggingLevel.Fatal => LoggingLevel.Fatal,
101-
Models.LoggingLevel.Information => LoggingLevel.Information,
102-
Models.LoggingLevel.Trace => LoggingLevel.Trace,
103-
Models.LoggingLevel.Warning => LoggingLevel.Warning,
104-
_ => LoggingLevel.Information
74+
foreach (Models.HostAddress configurationHostAddress in configurationModel.HostAddresses) {
75+
HostAddress hostAddress = new HostAddress { Uri = configurationHostAddress.Uri, };
76+
hostAddress.ServiceType = configurationHostAddress.ServiceType switch {
77+
Models.ServiceType.TransactionProcessorAcl => ServiceType.TransactionProcessorAcl,
78+
_ => ServiceType.Security
10579
};
10680

107-
return response;
81+
response.HostAddresses.Add(hostAddress);
10882
}
83+
84+
response.LogLevel = configurationModel.LogLevel switch {
85+
Models.LoggingLevel.Debug => LoggingLevel.Debug,
86+
Models.LoggingLevel.Error => LoggingLevel.Error,
87+
Models.LoggingLevel.Fatal => LoggingLevel.Fatal,
88+
Models.LoggingLevel.Information => LoggingLevel.Information,
89+
Models.LoggingLevel.Trace => LoggingLevel.Trace,
90+
Models.LoggingLevel.Warning => LoggingLevel.Warning,
91+
_ => LoggingLevel.Information
92+
};
93+
94+
return response;
10995
}
110-
}
96+
}

MobileConfiguration/Models/Models.cs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,10 @@ public enum ConfigurationType
5353

5454
}
5555

56-
public class ApplicationCentreConfiguration
57-
{
58-
public String ApplicationId { get; set; }
59-
public String AndroidKey { get; set; }
60-
public String IosKey { get; set; }
61-
public String MacosKey { get; set; }
62-
public String WindowsKey { get; set; }
63-
}
56+
public class ApplicationCentreConfiguration {
57+
public String ApplicationId { get; set; }
58+
public String AndroidKey { get; set; }
59+
public String IosKey { get; set; }
60+
public String MacosKey { get; set; }
61+
public String WindowsKey { get; set; }
6462
}

0 commit comments

Comments
 (0)