diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 0000000..af26007
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,23 @@
+[*.cs]
+
+
+# SA1404: Code analysis suppression should have justification
+dotnet_diagnostic.SA1404.severity = none
+
+# SA1633: File header
+dotnet_diagnostic.SA1633.severity = none
+
+# SA1101: Prefix local calls with this
+dotnet_diagnostic.SA1101.severity = none
+
+# SA1611: Element parameters should be documented
+dotnet_diagnostic.SA1611.severity = none
+
+# SA1309: starting underscore
+dotnet_diagnostic.SA1309.severity = none
+
+dotnet_diagnostic.SA1615.severity = none
+
+dotnet_diagnostic.SA1642.severity = none
+
+dotnet_diagnostic.SA1623.severity = none
\ No newline at end of file
diff --git a/.gitignore b/.gitignore
index f0be35e..280df84 100644
--- a/.gitignore
+++ b/.gitignore
@@ -132,3 +132,4 @@ $RECYCLE.BIN/
_NCrunch*
*.idea*
+.vs
diff --git a/AdvancedAPI.Business/AdvancedAPI.Business.csproj b/AdvancedAPI.Business/AdvancedAPI.Business.csproj
index ce311ae..06d6311 100644
--- a/AdvancedAPI.Business/AdvancedAPI.Business.csproj
+++ b/AdvancedAPI.Business/AdvancedAPI.Business.csproj
@@ -6,13 +6,23 @@
enable
dotnet-Business-63FD5173-E1FF-446F-A3C3-0D5E7DA4C0FF
Business
+ bin\$(Configuration)\$(TargetFramework)\$(AssemblyName).xml
-
+
-
+
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
+
+
+
+
+
diff --git a/AdvancedAPI.Business/Program.cs b/AdvancedAPI.Business/Program.cs
index 4e7dfb7..9251f9f 100644
--- a/AdvancedAPI.Business/Program.cs
+++ b/AdvancedAPI.Business/Program.cs
@@ -4,4 +4,4 @@
.ConfigureServices(services => { services.AddHostedService(); })
.Build();
-await host.RunAsync();
\ No newline at end of file
+await host.RunAsync();
diff --git a/AdvancedAPI.Business/Services/HouseService.cs b/AdvancedAPI.Business/Services/HouseService.cs
index f6f883b..867a976 100644
--- a/AdvancedAPI.Business/Services/HouseService.cs
+++ b/AdvancedAPI.Business/Services/HouseService.cs
@@ -6,10 +6,10 @@
namespace Business.Services;
///
-public class HouseService: IHouseService
+public class HouseService : IHouseService
{
-
private readonly IHouseRepository _houseRepository;
+
///
/// Constructor.
///
@@ -30,4 +30,4 @@ public HouseService(IHouseRepository houseRepository)
return new List();
}
-}
\ No newline at end of file
+}
diff --git a/AdvancedAPI.Business/Services/Interfaces/IHouseService.cs b/AdvancedAPI.Business/Services/Interfaces/IHouseService.cs
index bc4d1ca..fdc86bd 100644
--- a/AdvancedAPI.Business/Services/Interfaces/IHouseService.cs
+++ b/AdvancedAPI.Business/Services/Interfaces/IHouseService.cs
@@ -8,7 +8,7 @@ namespace Business.Services.Interfaces;
public interface IHouseService
{
///
- /// Obtaining List of all houses
+ /// Obtaining List of all houses.
///
public Task?> GetAllHouses(CancellationToken ct = default);
-}
\ No newline at end of file
+}
diff --git a/AdvancedAPI.Business/Worker.cs b/AdvancedAPI.Business/Worker.cs
index 83cd296..5cf5dda 100644
--- a/AdvancedAPI.Business/Worker.cs
+++ b/AdvancedAPI.Business/Worker.cs
@@ -1,14 +1,23 @@
namespace Business;
+///
+/// Default.
+///
public class Worker : BackgroundService
{
private readonly ILogger _logger;
+ ///
+ /// Default.
+ ///
public Worker(ILogger logger)
{
_logger = logger;
}
+ ///
+ /// Default.
+ ///
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
{
while (!stoppingToken.IsCancellationRequested)
@@ -17,4 +26,4 @@ protected override async Task ExecuteAsync(CancellationToken stoppingToken)
await Task.Delay(1000, stoppingToken);
}
}
-}
\ No newline at end of file
+}
diff --git a/AdvancedAPI.Data/AdvancedAPI.Data.csproj b/AdvancedAPI.Data/AdvancedAPI.Data.csproj
index 93af82b..294a96f 100644
--- a/AdvancedAPI.Data/AdvancedAPI.Data.csproj
+++ b/AdvancedAPI.Data/AdvancedAPI.Data.csproj
@@ -5,10 +5,19 @@
enable
enable
dotnet-AdvancedAPI.Data-FC4EB265-FB30-4113-B83E-B67571392567
+ bin\$(Configuration)\$(TargetFramework)\$(AssemblyName).xml
-
+
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
+
+
+
+
diff --git a/AdvancedAPI.Data/Models/House.cs b/AdvancedAPI.Data/Models/House.cs
index 4b94e0d..ab64f0c 100644
--- a/AdvancedAPI.Data/Models/House.cs
+++ b/AdvancedAPI.Data/Models/House.cs
@@ -1,6 +1,8 @@
namespace AdvancedAPI.Data.Models;
+///
+/// Model of house.
+///
public class House
{
-
-}
\ No newline at end of file
+}
diff --git a/AdvancedAPI.Data/Program.cs b/AdvancedAPI.Data/Program.cs
index d80dd1a..c90b847 100644
--- a/AdvancedAPI.Data/Program.cs
+++ b/AdvancedAPI.Data/Program.cs
@@ -4,4 +4,4 @@
.ConfigureServices(services => { services.AddHostedService(); })
.Build();
-await host.RunAsync();
\ No newline at end of file
+await host.RunAsync();
diff --git a/AdvancedAPI.Data/Repositories/HouseRepository.cs b/AdvancedAPI.Data/Repositories/HouseRepository.cs
index ab3d5a4..f4aef84 100644
--- a/AdvancedAPI.Data/Repositories/HouseRepository.cs
+++ b/AdvancedAPI.Data/Repositories/HouseRepository.cs
@@ -3,12 +3,12 @@
namespace AdvancedAPI.Data.Repositories;
-///
-public class HouseRepository: IHouseRepository
+///
+public class HouseRepository : IHouseRepository
{
///
public Task> GetAllHouses()
{
throw new NotImplementedException();
}
-}
\ No newline at end of file
+}
diff --git a/AdvancedAPI.Data/Repositories/Interfaces/IHouseRepository.cs b/AdvancedAPI.Data/Repositories/Interfaces/IHouseRepository.cs
index c857dc7..6be84dc 100644
--- a/AdvancedAPI.Data/Repositories/Interfaces/IHouseRepository.cs
+++ b/AdvancedAPI.Data/Repositories/Interfaces/IHouseRepository.cs
@@ -10,6 +10,5 @@ public interface IHouseRepository
///
/// obtaining a List of .
///
- ///
public Task> GetAllHouses();
-}
\ No newline at end of file
+}
diff --git a/AdvancedAPI.Data/ViewModels/ErrorResponseModel.cs b/AdvancedAPI.Data/ViewModels/ErrorResponseModel.cs
index 88e1a94..ea61a47 100644
--- a/AdvancedAPI.Data/ViewModels/ErrorResponseModel.cs
+++ b/AdvancedAPI.Data/ViewModels/ErrorResponseModel.cs
@@ -1,8 +1,17 @@
-namespace AdvancedAPI.Models;
+namespace AdvancedAPI.Data.ViewModels;
+///
+/// Error response model. Will be sent to the requester.
+///
public class ErrorResponseModel
{
- public string? RequestId { get; set; }
+ ///
+ /// Status code of the error.
+ ///
+ public int Code { get; set; }
- public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
-}
\ No newline at end of file
+ ///
+ /// Message of the error.
+ ///
+ public string Message { get; set; } = string.Empty;
+}
diff --git a/AdvancedAPI.Data/ViewModels/Houses/HouseResponseModel.cs b/AdvancedAPI.Data/ViewModels/Houses/HouseResponseModel.cs
index c999eef..00d7421 100644
--- a/AdvancedAPI.Data/ViewModels/Houses/HouseResponseModel.cs
+++ b/AdvancedAPI.Data/ViewModels/Houses/HouseResponseModel.cs
@@ -11,6 +11,6 @@ public class HouseResponseModel
///
/// Name of the street where the house is located.
///
- [JsonProperty("street Name")]
- public string StreetName { get; set; } = String.Empty;
-}
\ No newline at end of file
+ [JsonProperty("street Name")]
+ public string StreetName { get; set; } = string.Empty;
+}
diff --git a/AdvancedAPI.Data/Worker.cs b/AdvancedAPI.Data/Worker.cs
index 98f4967..cf585b1 100644
--- a/AdvancedAPI.Data/Worker.cs
+++ b/AdvancedAPI.Data/Worker.cs
@@ -1,14 +1,23 @@
namespace AdvancedAPI.Data;
+///
+/// Default.
+///
public class Worker : BackgroundService
{
private readonly ILogger _logger;
+ ///
+ /// Default.
+ ///
public Worker(ILogger logger)
{
_logger = logger;
}
+ ///
+ /// Default.
+ ///
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
{
while (!stoppingToken.IsCancellationRequested)
@@ -17,4 +26,4 @@ protected override async Task ExecuteAsync(CancellationToken stoppingToken)
await Task.Delay(1000, stoppingToken);
}
}
-}
\ No newline at end of file
+}
diff --git a/AdvancedAPI.Tests/AdvancedAPI.Tests.csproj b/AdvancedAPI.Tests/AdvancedAPI.Tests.csproj
index a9afa52..3c8ea7a 100644
--- a/AdvancedAPI.Tests/AdvancedAPI.Tests.csproj
+++ b/AdvancedAPI.Tests/AdvancedAPI.Tests.csproj
@@ -4,10 +4,9 @@
net6.0
enable
enable
-
false
-
Tests
+ bin\$(Configuration)\$(TargetFramework)\$(AssemblyName).xml
@@ -16,6 +15,10 @@
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
runtime; build; native; contentfiles; analyzers; buildtransitive
@@ -35,4 +38,8 @@
+
+
+
+
diff --git a/AdvancedAPI.Tests/Services/HouseServiceTests.cs b/AdvancedAPI.Tests/Services/HouseServiceTests.cs
index 8fe7ada..3aeeebd 100644
--- a/AdvancedAPI.Tests/Services/HouseServiceTests.cs
+++ b/AdvancedAPI.Tests/Services/HouseServiceTests.cs
@@ -15,6 +15,7 @@ public class HouseServiceTests
{
private readonly IHouseService _houseService;
private readonly Mock _houseRepository;
+
///
/// Constructor.
///
@@ -32,18 +33,19 @@ public HouseServiceTests()
public async Task GetAllHousesReturnsNull()
{
_houseRepository.Setup(x => x.GetAllHouses()).ReturnsAsync(new List());
- var result = await _houseService.GetAllHouses();
- Assert.Equal(null, result);
+ List? result = await _houseService.GetAllHouses();
+
+ Assert.Null(result);
}
-
+
///
/// Tests if returns a valid list.
///
[Fact]
public async Task GetAllHousesReturnsList()
{
- _houseRepository.Setup(x => x.GetAllHouses()).ReturnsAsync(new List{new()});
- var result = await _houseService.GetAllHouses();
+ _houseRepository.Setup(x => x.GetAllHouses()).ReturnsAsync(new List { new() });
+ List? result = await _houseService.GetAllHouses();
Assert.Equal(new List(), result);
}
-}
\ No newline at end of file
+}
diff --git a/AdvancedAPI.Tests/Usings.cs b/AdvancedAPI.Tests/Usings.cs
index 8c927eb..c802f44 100644
--- a/AdvancedAPI.Tests/Usings.cs
+++ b/AdvancedAPI.Tests/Usings.cs
@@ -1 +1 @@
-global using Xunit;
\ No newline at end of file
+global using Xunit;
diff --git a/AdvancedAPI.sln b/AdvancedAPI.sln
index e68cd04..10533ba 100644
--- a/AdvancedAPI.sln
+++ b/AdvancedAPI.sln
@@ -1,12 +1,20 @@
Microsoft Visual Studio Solution File, Format Version 12.00
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AdvancedAPI", "AdvancedAPI\AdvancedAPI.csproj", "{C8B1A7A2-655B-4CC4-83B8-317E47737D64}"
+# Visual Studio Version 17
+VisualStudioVersion = 17.5.33516.290
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AdvancedAPI", "AdvancedAPI\AdvancedAPI.csproj", "{C8B1A7A2-655B-4CC4-83B8-317E47737D64}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AdvancedAPI.Tests", "AdvancedAPI.Tests\AdvancedAPI.Tests.csproj", "{68B1C0FF-763F-49DC-B214-1EA6687BC8BE}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AdvancedAPI.Tests", "AdvancedAPI.Tests\AdvancedAPI.Tests.csproj", "{68B1C0FF-763F-49DC-B214-1EA6687BC8BE}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AdvancedAPI.Business", "AdvancedAPI.Business\AdvancedAPI.Business.csproj", "{5B50610A-4319-4A94-B572-C206F2D4854C}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AdvancedAPI.Business", "AdvancedAPI.Business\AdvancedAPI.Business.csproj", "{5B50610A-4319-4A94-B572-C206F2D4854C}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AdvancedAPI.Data", "AdvancedAPI.Data\AdvancedAPI.Data.csproj", "{00677115-7649-43C1-BDA6-27F403170575}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AdvancedAPI.Data", "AdvancedAPI.Data\AdvancedAPI.Data.csproj", "{00677115-7649-43C1-BDA6-27F403170575}"
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{086D46AA-3EB5-4C94-980B-F9DDCE428E3F}"
+ ProjectSection(SolutionItems) = preProject
+ .editorconfig = .editorconfig
+ EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -31,4 +39,7 @@ Global
{00677115-7649-43C1-BDA6-27F403170575}.Release|Any CPU.ActiveCfg = Release|Any CPU
{00677115-7649-43C1-BDA6-27F403170575}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
EndGlobal
diff --git a/AdvancedAPI/AdvancedAPI.csproj b/AdvancedAPI/AdvancedAPI.csproj
index 695502b..6cce91c 100644
--- a/AdvancedAPI/AdvancedAPI.csproj
+++ b/AdvancedAPI/AdvancedAPI.csproj
@@ -8,9 +8,14 @@
true
$(NoWarn);1591
+ True
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
@@ -18,5 +23,9 @@
+
+
+
+
diff --git a/AdvancedAPI/Controllers/HouseController.cs b/AdvancedAPI/Controllers/HouseController.cs
index 2692366..65c4c14 100644
--- a/AdvancedAPI/Controllers/HouseController.cs
+++ b/AdvancedAPI/Controllers/HouseController.cs
@@ -1,33 +1,48 @@
-using System.Net;
+using AdvancedAPI.Data.ViewModels;
using AdvancedAPI.Data.ViewModels.Houses;
-using AdvancedAPI.Models;
+using Business.Services.Interfaces;
using Microsoft.AspNetCore.Mvc;
namespace AdvancedAPI.Controllers;
+
///
/// House api provided operation to main the houses.
///
-[ApiController, Route("api/house")]
+[ApiController]
+[Route("api/house")]
public class HouseController : ControllerBase
{
+ private readonly IHouseService _houseService;
- ///
- /// Constructor.
- ///
- public HouseController()
+ private HouseController(IHouseService houseService)
{
+ _houseService = houseService;
}
///
/// Obtains a list of houses.
///
- [HttpGet, Route("overview")]
+ /// List of houses.
+ [HttpGet]
+ [Route("overview")]
[ProducesResponseType(typeof(List), 200)]
[ProducesResponseType(typeof(ErrorResponseModel), 401)]
[ProducesResponseType(typeof(ErrorResponseModel), 404)]
[ProducesResponseType(typeof(ErrorResponseModel), 500)]
public async Task Overview(CancellationToken cancellationToken = default)
{
+ List? houseResponseModels = await _houseService.GetAllHouses(cancellationToken);
+
+ if (houseResponseModels == null || !houseResponseModels.Any())
+ {
+ return NotFound(
+ new ErrorResponseModel
+ {
+ Code = 404,
+ Message = "No houses found",
+ });
+ }
+
return Ok(new List());
}
-}
\ No newline at end of file
+}
diff --git a/AdvancedAPI/GlobalSuppressions.cs b/AdvancedAPI/GlobalSuppressions.cs
new file mode 100644
index 0000000..48f7b78
--- /dev/null
+++ b/AdvancedAPI/GlobalSuppressions.cs
@@ -0,0 +1,3 @@
+using System.Diagnostics.CodeAnalysis;
+
+[assembly: SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1642:Constructor summary documentation should begin with standard text", Justification = "", Scope = "member", Target = "~M:AdvancedAPI.Controllers.HouseController.#ctor")]
diff --git a/AdvancedAPI/Program.cs b/AdvancedAPI/Program.cs
index 558c2c1..022cbea 100644
--- a/AdvancedAPI/Program.cs
+++ b/AdvancedAPI/Program.cs
@@ -11,9 +11,9 @@
{
Title = "AdvancedAPI",
Version = "v1",
- Description = "The Advanced API of DustSwiffer"
+ Description = "The Advanced API of DustSwiffer",
});
-
+
var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile);
c.IncludeXmlComments(xmlPath);
@@ -25,6 +25,7 @@
if (!app.Environment.IsDevelopment())
{
app.UseExceptionHandler("/Home/Error");
+
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts();
}
@@ -47,4 +48,4 @@
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");
-app.Run();
\ No newline at end of file
+app.Run();