MC # Swagger model fix (gen), MongoDB pswd, Token to Json update

This commit is contained in:
ThomasFransolet 2019-07-11 23:23:57 +02:00
parent 7ca1306004
commit 1c6b1a3cce
13 changed files with 39 additions and 4 deletions

View File

@ -26,6 +26,7 @@ namespace MyCore.Controllers
/// <summary> /// <summary>
/// Retrieve all SmartPrinterMessage /// Retrieve all SmartPrinterMessage
/// </summary> /// </summary>
/// <param name="id">Id of the smart printer message</param>
[HttpGet("smartprinter/{idDevice}")] [HttpGet("smartprinter/{idDevice}")]
public ActionResult<List<SmartPrinterMessage>> GetSmartPrinterMessages(int id) public ActionResult<List<SmartPrinterMessage>> GetSmartPrinterMessages(int id)
{ {
@ -36,6 +37,10 @@ namespace MyCore.Controllers
/// <summary> /// <summary>
/// It's the method to post data from mqtt broker to Database (Thanks Rpi!) /// It's the method to post data from mqtt broker to Database (Thanks Rpi!)
/// </summary> /// </summary>
/// <param name="idDevice">Id of the device to upload to DB</param>
/// <param name="content">Content that will be uploaded</param>
/// <response code="201">Content successfully posted to DB</response>
/// <response code="500">Unexpected error</response>
[HttpPost("smartprinter/{idDevice}")] [HttpPost("smartprinter/{idDevice}")]
public IActionResult PostToDBPrinter(int idDevice, [FromBody] SmartPrinterMessage[] content) public IActionResult PostToDBPrinter(int idDevice, [FromBody] SmartPrinterMessage[] content)
{ {

View File

@ -23,7 +23,7 @@ namespace MyCore.Controllers
public IActionResult Create(string username, string password) public IActionResult Create(string username, string password)
{ {
if (IsValidUserAndPasswordCombination(username, password)) if (IsValidUserAndPasswordCombination(username, password))
return new ObjectResult(GenerateToken(username)); return new ObjectResult("{\"Token\":\""+GenerateToken(username)+"\"}");
return BadRequest(); return BadRequest();
} }

View File

@ -84,6 +84,10 @@ namespace MyCore
public void Configure(IApplicationBuilder app, IHostingEnvironment env) public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{ {
app.UseCors(
options => options.WithOrigins("http://localhost:4200").AllowAnyMethod()
);
// Enable middleware to serve generated Swagger as a JSON endpoint. // Enable middleware to serve generated Swagger as a JSON endpoint.
app.UseSwagger(); app.UseSwagger();

View File

@ -1,7 +1,7 @@
{ {
"ConnectionStrings": { "ConnectionStrings": {
"BookstoreDb": "mongodb://localhost:27017", "BookstoreDb": "mongodb://admin:MioTech4ever!@localhost:27017",
"MyCoreDb": "mongodb://localhost:27017" "MyCoreDb": "mongodb://admin:MioTech4ever!@localhost:27017"
}, },
"Logging": { "Logging": {
"LogLevel": { "LogLevel": {

View File

@ -8,11 +8,16 @@
<summary> <summary>
Retrieve all SmartPrinterMessage Retrieve all SmartPrinterMessage
</summary> </summary>
<param name="id">Id of the smart printer message</param>
</member> </member>
<member name="M:MyCore.Controllers.IOTController.PostToDBPrinter(System.Int32,MyCore.Models.SmartPrinterMessage[])"> <member name="M:MyCore.Controllers.IOTController.PostToDBPrinter(System.Int32,MyCore.Models.SmartPrinterMessage[])">
<summary> <summary>
It's the method to post data from mqtt broker to Database (Thanks Rpi!) It's the method to post data from mqtt broker to Database (Thanks Rpi!)
</summary> </summary>
<param name="idDevice">Id of the device to upload to DB</param>
<param name="content">Content that will be uploaded</param>
<response code="201">Content successfully posted to DB</response>
<response code="500">Unexpected error</response>
</member> </member>
<member name="M:MyCore.Controllers.IOTController.PostToDBSmartGarden(System.Int32,MyCore.Models.SmartGardenMessage[])"> <member name="M:MyCore.Controllers.IOTController.PostToDBSmartGarden(System.Int32,MyCore.Models.SmartGardenMessage[])">
<summary> <summary>

View File

@ -19,7 +19,6 @@ C:\Users\thoma\OneDrive\Documents\Travail\MyCore\MyCore\bin\Debug\netcoreapp2.1\
C:\Users\thoma\OneDrive\Documents\Travail\MyCore\MyCore\bin\Debug\netcoreapp2.1\MyCore.runtimeconfig.json C:\Users\thoma\OneDrive\Documents\Travail\MyCore\MyCore\bin\Debug\netcoreapp2.1\MyCore.runtimeconfig.json
C:\Users\thoma\OneDrive\Documents\Travail\MyCore\MyCore\bin\Debug\netcoreapp2.1\MyCore.runtimeconfig.dev.json C:\Users\thoma\OneDrive\Documents\Travail\MyCore\MyCore\bin\Debug\netcoreapp2.1\MyCore.runtimeconfig.dev.json
C:\Users\thoma\OneDrive\Documents\Travail\MyCore\MyCore\bin\Debug\netcoreapp2.1\MyCore.dll C:\Users\thoma\OneDrive\Documents\Travail\MyCore\MyCore\bin\Debug\netcoreapp2.1\MyCore.dll
C:\Users\thoma\OneDrive\Documents\Travail\MyCore\MyCore\obj\Debug\netcoreapp2.1\MyCore.csprojAssemblyReference.cache
C:\Users\thoma\OneDrive\Documents\Travail\MyCore\MyCore\obj\Debug\netcoreapp2.1\MyCore.csproj.CoreCompileInputs.cache C:\Users\thoma\OneDrive\Documents\Travail\MyCore\MyCore\obj\Debug\netcoreapp2.1\MyCore.csproj.CoreCompileInputs.cache
C:\Users\thoma\OneDrive\Documents\Travail\MyCore\MyCore\obj\Debug\netcoreapp2.1\MyCore.RazorAssemblyInfo.cache C:\Users\thoma\OneDrive\Documents\Travail\MyCore\MyCore\obj\Debug\netcoreapp2.1\MyCore.RazorAssemblyInfo.cache
C:\Users\thoma\OneDrive\Documents\Travail\MyCore\MyCore\obj\Debug\netcoreapp2.1\MyCore.RazorAssemblyInfo.cs C:\Users\thoma\OneDrive\Documents\Travail\MyCore\MyCore\obj\Debug\netcoreapp2.1\MyCore.RazorAssemblyInfo.cs
@ -32,3 +31,4 @@ C:\Users\thoma\OneDrive\Documents\Travail\MyCore\MyCore\bin\Debug\netcoreapp2.1\
C:\Users\thoma\OneDrive\Documents\Travail\MyCore\MyCore\obj\Debug\netcoreapp2.1\MyCore.dll C:\Users\thoma\OneDrive\Documents\Travail\MyCore\MyCore\obj\Debug\netcoreapp2.1\MyCore.dll
C:\Users\thoma\OneDrive\Documents\Travail\MyCore\MyCore\obj\Debug\netcoreapp2.1\MyCore.pdb C:\Users\thoma\OneDrive\Documents\Travail\MyCore\MyCore\obj\Debug\netcoreapp2.1\MyCore.pdb
C:\Users\thoma\OneDrive\Documents\Travail\MyCore\MyCore\obj\Debug\netcoreapp2.1\UserSecretsAssemblyInfo.cs C:\Users\thoma\OneDrive\Documents\Travail\MyCore\MyCore\obj\Debug\netcoreapp2.1\UserSecretsAssemblyInfo.cs
C:\Users\thoma\OneDrive\Documents\Travail\MyCore\MyCore\obj\Debug\netcoreapp2.1\MyCore.csprojAssemblyReference.cache

View File

@ -8,11 +8,16 @@
<summary> <summary>
Retrieve all SmartPrinterMessage Retrieve all SmartPrinterMessage
</summary> </summary>
<param name="id">Id of the smart printer message</param>
</member> </member>
<member name="M:MyCore.Controllers.IOTController.PostToDBPrinter(System.Int32,MyCore.Models.SmartPrinterMessage[])"> <member name="M:MyCore.Controllers.IOTController.PostToDBPrinter(System.Int32,MyCore.Models.SmartPrinterMessage[])">
<summary> <summary>
It's the method to post data from mqtt broker to Database (Thanks Rpi!) It's the method to post data from mqtt broker to Database (Thanks Rpi!)
</summary> </summary>
<param name="idDevice">Id of the device to upload to DB</param>
<param name="content">Content that will be uploaded</param>
<response code="201">Content successfully posted to DB</response>
<response code="500">Unexpected error</response>
</member> </member>
<member name="M:MyCore.Controllers.IOTController.PostToDBSmartGarden(System.Int32,MyCore.Models.SmartGardenMessage[])"> <member name="M:MyCore.Controllers.IOTController.PostToDBSmartGarden(System.Int32,MyCore.Models.SmartGardenMessage[])">
<summary> <summary>

BIN
Screenshot_2.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

15
pswdMongoDB.txt Normal file
View File

@ -0,0 +1,15 @@
db.createUser(
{
user: "admin",
pwd: "MioTech4ever!",
roles: [ { role: "userAdminAnyDatabase", db: "admin" } ]
}
)
db.updateUser( "admin",
{
roles: [ { role: "userAdminAnyDatabase", db: "admin" },
{ role: "readWrite", db: "BookstoreDb" },
{ role: "readWrite", db: "MyCoreDb" } ]
}
)

1
swagger.json Normal file

File diff suppressed because one or more lines are too long