Skip to content

Commit 896032f

Browse files
committed
Update namespaces
1 parent 216bcee commit 896032f

15 files changed

+363
-377
lines changed

IdentityServerAngularOidcFlows.sln

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio Version 16
4-
VisualStudioVersion = 16.0.29311.281
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.0.32126.317
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{A0F6C07F-188D-4F86-B43F-4A3EAD0D2C30}"
77
EndProject
88
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{68FE7151-CB27-498E-8FC3-DB0EB76BED8A}"
99
ProjectSection(SolutionItems) = preProject
10-
appveyor.yml = appveyor.yml
10+
.github\workflows\dotnet.yml = .github\workflows\dotnet.yml
1111
README.md = README.md
1212
EndProjectSection
1313
EndProject

src/ResourceServer/Controllers/DataEventRecordController.cs

+45-46
Original file line numberDiff line numberDiff line change
@@ -3,52 +3,51 @@
33
using Microsoft.AspNetCore.Authorization;
44
using Microsoft.AspNetCore.Mvc;
55

6-
namespace ResourceServer.Controllers
6+
namespace ResourceServer.Controllers;
7+
8+
[Authorize("dataEventRecords")]
9+
[Route("api/[controller]")]
10+
public class DataEventRecordsController : Controller
711
{
8-
[Authorize("dataEventRecords")]
9-
[Route("api/[controller]")]
10-
public class DataEventRecordsController : Controller
12+
private readonly IDataEventRecordRepository _dataEventRecordRepository;
13+
14+
public DataEventRecordsController(IDataEventRecordRepository dataEventRecordRepository)
15+
{
16+
_dataEventRecordRepository = dataEventRecordRepository;
17+
}
18+
19+
[Authorize("dataEventRecordsUser")]
20+
[HttpGet]
21+
public IActionResult Get()
22+
{
23+
return Ok(_dataEventRecordRepository.GetAll());
24+
}
25+
26+
[Authorize("dataEventRecordsAdmin")]
27+
[HttpGet("{id}")]
28+
public IActionResult Get(long id)
29+
{
30+
return Ok(_dataEventRecordRepository.Get(id));
31+
}
32+
33+
[Authorize("dataEventRecordsAdmin")]
34+
[HttpPost]
35+
public void Post([FromBody] DataEventRecord value)
36+
{
37+
_dataEventRecordRepository.Post(value);
38+
}
39+
40+
[Authorize("dataEventRecordsAdmin")]
41+
[HttpPut("{id}")]
42+
public void Put(long id, [FromBody] DataEventRecord value)
43+
{
44+
_dataEventRecordRepository.Put(id, value);
45+
}
46+
47+
[Authorize("dataEventRecordsAdmin")]
48+
[HttpDelete("{id}")]
49+
public void Delete(long id)
1150
{
12-
private readonly IDataEventRecordRepository _dataEventRecordRepository;
13-
14-
public DataEventRecordsController(IDataEventRecordRepository dataEventRecordRepository)
15-
{
16-
_dataEventRecordRepository = dataEventRecordRepository;
17-
}
18-
19-
[Authorize("dataEventRecordsUser")]
20-
[HttpGet]
21-
public IActionResult Get()
22-
{
23-
return Ok(_dataEventRecordRepository.GetAll());
24-
}
25-
26-
[Authorize("dataEventRecordsAdmin")]
27-
[HttpGet("{id}")]
28-
public IActionResult Get(long id)
29-
{
30-
return Ok(_dataEventRecordRepository.Get(id));
31-
}
32-
33-
[Authorize("dataEventRecordsAdmin")]
34-
[HttpPost]
35-
public void Post([FromBody] DataEventRecord value)
36-
{
37-
_dataEventRecordRepository.Post(value);
38-
}
39-
40-
[Authorize("dataEventRecordsAdmin")]
41-
[HttpPut("{id}")]
42-
public void Put(long id, [FromBody] DataEventRecord value)
43-
{
44-
_dataEventRecordRepository.Put(id, value);
45-
}
46-
47-
[Authorize("dataEventRecordsAdmin")]
48-
[HttpDelete("{id}")]
49-
public void Delete(long id)
50-
{
51-
_dataEventRecordRepository.Delete(id);
52-
}
51+
_dataEventRecordRepository.Delete(id);
5352
}
54-
}
53+
}
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
using Microsoft.EntityFrameworkCore;
22

3-
namespace ResourceServer.DataProtection
3+
namespace ResourceServer.DataProtection;
4+
5+
public class DataProtectionDbContext : DbContext
46
{
5-
public class DataProtectionDbContext : DbContext
6-
{
7-
public DbSet<DataProtectionElement> DataProtectionXMLElements { get; set; }
7+
public DbSet<DataProtectionElement> DataProtectionXMLElements { get; set; }
88

9-
public DataProtectionDbContext(DbContextOptions<DataProtectionDbContext> options) : base(options)
10-
{
11-
}
9+
public DataProtectionDbContext(DbContextOptions<DataProtectionDbContext> options) : base(options)
10+
{
1211
}
1312
}

src/ResourceServer/DataProtection/DataProtectionDbContextFactory.cs

+14-15
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,24 @@
44
using System;
55
using System.IO;
66

7-
namespace ResourceServer.DataProtection
7+
namespace ResourceServer.DataProtection;
8+
9+
public class DataProtectionDbContextFactory : IDesignTimeDbContextFactory<DataProtectionDbContext>
810
{
9-
public class DataProtectionDbContextFactory : IDesignTimeDbContextFactory<DataProtectionDbContext>
11+
public DataProtectionDbContext CreateDbContext(string[] args)
1012
{
11-
public DataProtectionDbContext CreateDbContext(string[] args)
12-
{
13-
var deploymentType = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT", EnvironmentVariableTarget.Machine);
13+
var deploymentType = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT", EnvironmentVariableTarget.Machine);
1414

15-
var currentDirectory = Directory.GetCurrentDirectory();
15+
var currentDirectory = Directory.GetCurrentDirectory();
1616

17-
var configuration = new ConfigurationBuilder()
18-
.AddJsonFile($"{currentDirectory}\\appsettings.json")
19-
.Build();
17+
var configuration = new ConfigurationBuilder()
18+
.AddJsonFile($"{currentDirectory}\\appsettings.json")
19+
.Build();
2020

21-
var connectionString = configuration.GetConnectionString("DefaultConnection");
22-
var optionsBuilder = new DbContextOptionsBuilder<DataProtectionDbContext>();
23-
optionsBuilder.UseSqlite(connectionString);
21+
var connectionString = configuration.GetConnectionString("DefaultConnection");
22+
var optionsBuilder = new DbContextOptionsBuilder<DataProtectionDbContext>();
23+
optionsBuilder.UseSqlite(connectionString);
2424

25-
return new DataProtectionDbContext(optionsBuilder.Options);
26-
}
25+
return new DataProtectionDbContext(optionsBuilder.Options);
2726
}
28-
}
27+
}
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
using System;
22

3-
namespace ResourceServer.DataProtection
3+
namespace ResourceServer.DataProtection;
4+
5+
public class DataProtectionElement
46
{
5-
public class DataProtectionElement
7+
public DataProtectionElement()
68
{
7-
public DataProtectionElement()
8-
{
9-
Id = Guid.NewGuid();
10-
}
9+
Id = Guid.NewGuid();
10+
}
1111

12-
public Guid Id { get; set; }
12+
public Guid Id { get; set; }
1313

14-
public string Xml { get; set; }
15-
}
14+
public string Xml { get; set; }
1615
}

src/ResourceServer/DataProtection/SqlXmlRepository.cs

+22-23
Original file line numberDiff line numberDiff line change
@@ -4,32 +4,31 @@
44
using System.Linq;
55
using System.Xml.Linq;
66

7-
namespace ResourceServer.DataProtection
7+
namespace ResourceServer.DataProtection;
8+
9+
public class SqlXmlRepository : IXmlRepository
810
{
9-
public class SqlXmlRepository : IXmlRepository
10-
{
11-
private readonly DataProtectionDbContext DataProtectionDbContext;
11+
private readonly DataProtectionDbContext DataProtectionDbContext;
1212

13-
public SqlXmlRepository(DataProtectionDbContext context)
14-
{
15-
DataProtectionDbContext = context;
16-
}
13+
public SqlXmlRepository(DataProtectionDbContext context)
14+
{
15+
DataProtectionDbContext = context;
16+
}
1717

18-
public IReadOnlyCollection<XElement> GetAllElements()
19-
{
20-
return new ReadOnlyCollection<XElement>(DataProtectionDbContext.DataProtectionXMLElements.Select(x => XElement.Parse(x.Xml)).ToList());
21-
}
18+
public IReadOnlyCollection<XElement> GetAllElements()
19+
{
20+
return new ReadOnlyCollection<XElement>(DataProtectionDbContext.DataProtectionXMLElements.Select(x => XElement.Parse(x.Xml)).ToList());
21+
}
2222

23-
public void StoreElement(XElement element, string friendlyName)
24-
{
25-
DataProtectionDbContext.DataProtectionXMLElements.Add(
26-
new DataProtectionElement
27-
{
28-
Xml = element.ToString(SaveOptions.DisableFormatting)
29-
}
30-
);
23+
public void StoreElement(XElement element, string friendlyName)
24+
{
25+
DataProtectionDbContext.DataProtectionXMLElements.Add(
26+
new DataProtectionElement
27+
{
28+
Xml = element.ToString(SaveOptions.DisableFormatting)
29+
}
30+
);
3131

32-
DataProtectionDbContext.SaveChanges();
33-
}
32+
DataProtectionDbContext.SaveChanges();
3433
}
35-
}
34+
}
+8-9
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
namespace ResourceServer.Model
1+
namespace ResourceServer.Model;
2+
3+
public class DataEventRecord
24
{
3-
public class DataEventRecord
4-
{
5-
public long Id { get; set; }
6-
public string Name { get; set; }
5+
public long Id { get; set; }
6+
public string Name { get; set; }
77

8-
public string Description { get; set; }
8+
public string Description { get; set; }
99

10-
public string Timestamp { get; set; }
11-
}
12-
}
10+
public string Timestamp { get; set; }
11+
}
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
11
using Microsoft.EntityFrameworkCore;
22

3-
namespace ResourceServer.Model
3+
namespace ResourceServer.Model;
4+
5+
public class DataEventRecordContext : DbContext
46
{
5-
public class DataEventRecordContext : DbContext
7+
public DataEventRecordContext(DbContextOptions<DataEventRecordContext> options) : base(options)
68
{
7-
public DataEventRecordContext(DbContextOptions<DataEventRecordContext> options) : base(options)
8-
{
9-
}
9+
}
1010

11-
public DbSet<DataEventRecord> DataEventRecords { get; set; }
11+
public DbSet<DataEventRecord> DataEventRecords { get; set; }
1212

13-
protected override void OnModelCreating(ModelBuilder builder)
14-
{
15-
builder.Entity<DataEventRecord>().HasKey(m => m.Id);
16-
base.OnModelCreating(builder);
17-
}
13+
protected override void OnModelCreating(ModelBuilder builder)
14+
{
15+
builder.Entity<DataEventRecord>().HasKey(m => m.Id);
16+
base.OnModelCreating(builder);
1817
}
1918
}

0 commit comments

Comments
 (0)