Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
MPAI-MMM
mmm-tec
Commits
245a8502
Commit
245a8502
authored
Oct 17, 2024
by
cann-alberto
Browse files
Registration package : users, persona and device models
parent
bf2df72b
Changes
26
Hide whitespace changes
Inline
Side-by-side
MMM-Server/MMM-Server/Controllers/ProfilesController.cs
deleted
100644 → 0
View file @
bf2df72b
using
MMM_Server.Models
;
using
MMM_Server.Services
;
using
Microsoft.AspNetCore.Mvc
;
namespace
MMM_Server.Controllers
;
[
ApiController
]
[
Route
(
"api/[controller]"
)]
public
class
ProfilesController
:
ControllerBase
{
private
readonly
ProfileService
_profilesService
;
public
ProfilesController
(
ProfileService
profilesService
)
=>
_profilesService
=
profilesService
;
[
HttpGet
]
public
async
Task
<
List
<
Profile
>>
Get
()
=>
await
_profilesService
.
GetAsync
();
}
MMM-Server/MMM-Server/Controllers/RegistrationController.cs
View file @
245a8502
using
MMM_Server.Models
;
using
MMM_Server.Models
;
using
MMM_Server.Services
;
using
MMM_Server.Services
;
using
Microsoft.AspNetCore.Mvc
;
using
Microsoft.AspNetCore.Mvc
;
using
MMM_Server.Models.Utils
;
namespace
MMM_Server.Controllers
;
namespace
MMM_Server.Controllers
;
...
@@ -9,68 +10,22 @@ namespace MMM_Server.Controllers;
...
@@ -9,68 +10,22 @@ namespace MMM_Server.Controllers;
public
class
RegistrationController
:
ControllerBase
public
class
RegistrationController
:
ControllerBase
{
{
private
readonly
ProfileService
_profilesService
;
private
readonly
Personal
ProfileService
_p
ersonalP
rofilesService
;
public
RegistrationController
(
ProfileService
profilesService
)
=>
public
RegistrationController
(
Personal
ProfileService
profilesService
)
=>
_profilesService
=
profilesService
;
_p
ersonalP
rofilesService
=
profilesService
;
[
HttpGet
]
[
HttpGet
]
public
async
Task
<
List
<
Profile
>>
Get
()
=>
public
async
Task
<
List
<
PersonalProfile
>>
Get
()
=>
await
_profilesService
.
GetAsync
();
await
_personalProfilesService
.
GetAsync
();
[
HttpGet
(
"{id:length(24)}"
)]
public
async
Task
<
ActionResult
<
Profile
>>
Get
(
string
id
)
{
var
book
=
await
_profilesService
.
GetAsync
(
id
);
if
(
book
is
null
)
{
return
NotFound
();
}
return
book
;
}
[
HttpPost
]
[
HttpPost
]
public
async
Task
<
IActionResult
>
Post
(
Profile
newProfile
)
public
async
Task
<
IActionResult
>
Post
(
Personal
Profile
newP
ersonalP
rofile
)
{
{
await
_profilesService
.
CreateAsync
(
newProfile
);
await
_p
ersonalP
rofilesService
.
CreateAsync
(
newP
ersonalP
rofile
);
return
CreatedAtAction
(
nameof
(
Get
),
new
{
id
=
newProfile
.
Id
},
newProfile
);
return
CreatedAtAction
(
nameof
(
Get
),
new
{
id
=
newP
ersonalP
rofile
.
Id
},
newP
ersonalP
rofile
);
}
}
[
HttpPut
(
"{id:length(24)}"
)]
public
async
Task
<
IActionResult
>
Update
(
string
id
,
Profile
updatedProfile
)
{
var
profile
=
await
_profilesService
.
GetAsync
(
id
);
if
(
profile
is
null
)
{
return
NotFound
();
}
updatedProfile
.
Id
=
profile
.
Id
;
await
_profilesService
.
UpdateAsync
(
id
,
updatedProfile
);
return
NoContent
();
}
[
HttpDelete
(
"{id:length(24)}"
)]
public
async
Task
<
IActionResult
>
Delete
(
string
id
)
{
var
profile
=
await
_profilesService
.
GetAsync
(
id
);
if
(
profile
is
null
)
{
return
NotFound
();
}
await
_profilesService
.
RemoveAsync
(
id
);
return
NoContent
();
}
}
}
...
...
MMM-Server/MMM-Server/Controllers/RightController.cs
deleted
100644 → 0
View file @
bf2df72b
namespace
MMM_Server.Controllers
{
public
class
RightController
{
}
}
MMM-Server/MMM-Server/Models/Device.cs
0 → 100644
View file @
245a8502
using
MongoDB.Bson.Serialization.Attributes
;
using
MongoDB.Bson
;
namespace
MMM_Server.Models
{
public
class
Device
{
[
BsonId
]
[
BsonRepresentation
(
BsonType
.
ObjectId
)]
public
string
?
Id
{
get
;
set
;
}
}
}
MMM-Server/MMM-Server/Models/Persona.cs
0 → 100644
View file @
245a8502
using
MongoDB.Bson.Serialization.Attributes
;
using
MongoDB.Bson
;
namespace
MMM_Server.Models
{
public
class
Persona
{
[
BsonId
]
[
BsonRepresentation
(
BsonType
.
ObjectId
)]
public
string
?
Id
{
get
;
set
;
}
public
string
Model
{
get
;
set
;
}
=
null
!;
}
}
MMM-Server/MMM-Server/Models/PersonalProfile.cs
0 → 100644
View file @
245a8502
using
MongoDB.Bson.Serialization.Attributes
;
using
MongoDB.Bson
;
namespace
MMM_Server.Models
{
public
class
PersonalProfile
{
[
BsonId
]
[
BsonRepresentation
(
BsonType
.
ObjectId
)]
public
string
?
Id
{
get
;
set
;
}
public
string
Header
{
get
;
set
;
}
=
null
!;
public
string
MInstanceID
{
get
;
set
;
}
=
null
!;
public
string
HumanID
{
get
;
set
;
}
=
null
!;
public
string
PersonalProfileID
{
get
;
set
;
}
=
null
!;
public
PersonalProfileData
PersonalProfileData
{
get
;
set
;
}
=
null
!;
public
string
DescrMetadata
{
get
;
set
;
}
=
null
!;
}
}
MMM-Server/MMM-Server/Models/Profile.cs
→
MMM-Server/MMM-Server/Models/
Personal
Profile
Data
.cs
View file @
245a8502
...
@@ -4,12 +4,8 @@ using MongoDB.Bson.Serialization.Attributes;
...
@@ -4,12 +4,8 @@ using MongoDB.Bson.Serialization.Attributes;
namespace
MMM_Server.Models
;
namespace
MMM_Server.Models
;
public
class
Profile
public
class
Personal
Profile
Data
{
{
[
BsonId
]
[
BsonRepresentation
(
BsonType
.
ObjectId
)]
public
string
?
Id
{
get
;
set
;
}
public
string
FirstName
{
get
;
set
;
}
=
null
!;
public
string
FirstName
{
get
;
set
;
}
=
null
!;
public
string
LastName
{
get
;
set
;
}
=
null
!;
public
string
LastName
{
get
;
set
;
}
=
null
!;
...
...
MMM-Server/MMM-Server/Models/User.cs
0 → 100644
View file @
245a8502
using
MongoDB.Bson.Serialization.Attributes
;
using
MongoDB.Bson
;
namespace
MMM_Server.Models
{
public
class
User
{
[
BsonId
]
[
BsonRepresentation
(
BsonType
.
ObjectId
)]
public
string
?
Id
{
get
;
set
;
}
}
}
MMM-Server/MMM-Server/Models/Utils/RegistrationInfo.cs
0 → 100644
View file @
245a8502
namespace
MMM_Server.Models.Utils
{
public
class
RegistrationInfo
{
public
PersonalProfileData
newProfile
{
get
;
set
;
}
=
null
!;
public
User
newUser
{
get
;
set
;
}
=
null
!;
public
Device
newdevice
{
get
;
set
;
}
=
null
!;
public
Persona
newPersona
{
get
;
set
;
}
=
null
!;
}
}
MMM-Server/MMM-Server/Program.cs
View file @
245a8502
...
@@ -5,7 +5,7 @@ var builder = WebApplication.CreateBuilder(args);
...
@@ -5,7 +5,7 @@ var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
// Add services to the container.
builder
.
Services
.
Configure
<
MMMDatabaseSettings
>(
builder
.
Configuration
.
GetSection
(
"ProfileDatabase"
));
builder
.
Services
.
Configure
<
MMMDatabaseSettings
>(
builder
.
Configuration
.
GetSection
(
"ProfileDatabase"
));
builder
.
Services
.
AddSingleton
<
ProfileService
>();
builder
.
Services
.
AddSingleton
<
Personal
ProfileService
>();
builder
.
Services
.
AddControllers
();
builder
.
Services
.
AddControllers
();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
...
...
MMM-Server/MMM-Server/Services/ProfileService.cs
→
MMM-Server/MMM-Server/Services/
Personal
ProfileService.cs
View file @
245a8502
...
@@ -4,10 +4,10 @@ using MongoDB.Driver;
...
@@ -4,10 +4,10 @@ using MongoDB.Driver;
namespace
MMM_Server.Services
;
namespace
MMM_Server.Services
;
public
class
ProfileService
public
class
Personal
ProfileService
{
{
private
readonly
IMongoCollection
<
Profile
>
_profilesCollection
;
private
readonly
IMongoCollection
<
Personal
Profile
>
_profilesCollection
;
public
ProfileService
(
public
Personal
ProfileService
(
IOptions
<
MMMDatabaseSettings
>
profileDatabaseSettings
)
IOptions
<
MMMDatabaseSettings
>
profileDatabaseSettings
)
{
{
var
mongoClient
=
new
MongoClient
(
var
mongoClient
=
new
MongoClient
(
...
@@ -16,23 +16,27 @@ public class ProfileService
...
@@ -16,23 +16,27 @@ public class ProfileService
var
mongoDatabase
=
mongoClient
.
GetDatabase
(
var
mongoDatabase
=
mongoClient
.
GetDatabase
(
profileDatabaseSettings
.
Value
.
DatabaseName
);
profileDatabaseSettings
.
Value
.
DatabaseName
);
_profilesCollection
=
mongoDatabase
.
GetCollection
<
Profile
>(
_profilesCollection
=
mongoDatabase
.
GetCollection
<
Personal
Profile
>(
profileDatabaseSettings
.
Value
.
ProfilesCollectionName
);
profileDatabaseSettings
.
Value
.
ProfilesCollectionName
);
}
}
public
async
Task
<
List
<
Profile
>>
GetAsync
()
=>
public
async
Task
<
List
<
Personal
Profile
>>
GetAsync
()
=>
await
_profilesCollection
.
Find
(
_
=>
true
).
ToListAsync
();
await
_profilesCollection
.
Find
(
_
=>
true
).
ToListAsync
();
public
async
Task
<
Profile
?>
GetAsync
(
string
id
)
=>
public
async
Task
CreateAsync
(
PersonalProfile
newProfile
)
=>
await
_profilesCollection
.
InsertOneAsync
(
newProfile
);
/*
public async Task<PersonalProfileData?> GetAsync(string id) =>
await _profilesCollection.Find(x => x.Id == id).FirstOrDefaultAsync();
await _profilesCollection.Find(x => x.Id == id).FirstOrDefaultAsync();
public
async
Task
CreateAsync
(
Profile
newBook
)
=>
await
_profilesCollection
.
InsertOneAsync
(
newBook
);
public
async
Task
UpdateAsync
(
string
id
,
Profile
updated
Book
)
=>
public async Task UpdateAsync(string id,
Personal
Profile
Data
updated
Profile
) =>
await
_profilesCollection
.
ReplaceOneAsync
(
x
=>
x
.
Id
==
id
,
updated
Book
);
await _profilesCollection.ReplaceOneAsync(x => x.Id == id, updated
Profile
);
public async Task RemoveAsync(string id) =>
public async Task RemoveAsync(string id) =>
await _profilesCollection.DeleteOneAsync(x => x.Id == id);
await _profilesCollection.DeleteOneAsync(x => x.Id == id);
*/
}
}
MMM-Server/MMM-Server/appsettings.json
View file @
245a8502
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
"ProfileDatabase"
:
{
"ProfileDatabase"
:
{
"ConnectionString"
:
"mongodb://localhost:27017"
,
"ConnectionString"
:
"mongodb://localhost:27017"
,
"DatabaseName"
:
"MMM"
,
"DatabaseName"
:
"MMM"
,
"ProfilesCollectionName"
:
"Profiles"
"ProfilesCollectionName"
:
"
Personal
Profiles"
},
},
"Logging"
:
{
"Logging"
:
{
"LogLevel"
:
{
"LogLevel"
:
{
...
...
MMM-Server/MMM-Server/bin/Debug/net8.0/MMM-Server.dll
View file @
245a8502
No preview for this file type
MMM-Server/MMM-Server/bin/Debug/net8.0/MMM-Server.exe
View file @
245a8502
No preview for this file type
MMM-Server/MMM-Server/bin/Debug/net8.0/MMM-Server.pdb
View file @
245a8502
No preview for this file type
MMM-Server/MMM-Server/bin/Debug/net8.0/appsettings.json
View file @
245a8502
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
"ProfileDatabase"
:
{
"ProfileDatabase"
:
{
"ConnectionString"
:
"mongodb://localhost:27017"
,
"ConnectionString"
:
"mongodb://localhost:27017"
,
"DatabaseName"
:
"MMM"
,
"DatabaseName"
:
"MMM"
,
"ProfilesCollectionName"
:
"Profiles"
"ProfilesCollectionName"
:
"
Personal
Profiles"
},
},
"Logging"
:
{
"Logging"
:
{
"LogLevel"
:
{
"LogLevel"
:
{
...
...
MMM-Server/MMM-Server/obj/Debug/net8.0/ApiEndpoints.json
View file @
245a8502
[
[
{
"ContainingType"
:
"MMM_Server.Controllers.ProfilesController"
,
"Method"
:
"Get"
,
"RelativePath"
:
"api/Profiles"
,
"HttpMethod"
:
"GET"
,
"IsController"
:
true
,
"Order"
:
0
,
"Parameters"
:
[],
"ReturnTypes"
:
[
{
"Type"
:
"System.Collections.Generic.List
\u
00601[[MMM_Server.Models.Profile, MMM-Server, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]"
,
"MediaTypes"
:
[
"text/plain"
,
"application/json"
,
"text/json"
],
"StatusCode"
:
200
}
]
},
{
{
"ContainingType"
:
"MMM_Server.Controllers.RegistrationController"
,
"ContainingType"
:
"MMM_Server.Controllers.RegistrationController"
,
"Method"
:
"Get"
,
"Method"
:
"Get"
,
...
@@ -29,7 +9,7 @@
...
@@ -29,7 +9,7 @@
"Parameters"
:
[],
"Parameters"
:
[],
"ReturnTypes"
:
[
"ReturnTypes"
:
[
{
{
"Type"
:
"System.Collections.Generic.List
\u
00601[[MMM_Server.Models.Profile, MMM-Server, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]"
,
"Type"
:
"System.Collections.Generic.List
\u
00601[[MMM_Server.Models.
Personal
Profile, MMM-Server, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]"
,
"MediaTypes"
:
[
"MediaTypes"
:
[
"text/plain"
,
"text/plain"
,
"application/json"
,
"application/json"
,
...
@@ -48,71 +28,8 @@
...
@@ -48,71 +28,8 @@
"Order"
:
0
,
"Order"
:
0
,
"Parameters"
:
[
"Parameters"
:
[
{
{
"Name"
:
"newProfile"
,
"Name"
:
"newPersonalProfile"
,
"Type"
:
"MMM_Server.Models.Profile"
,
"Type"
:
"MMM_Server.Models.PersonalProfile"
,
"IsRequired"
:
true
}
],
"ReturnTypes"
:
[]
},
{
"ContainingType"
:
"MMM_Server.Controllers.RegistrationController"
,
"Method"
:
"Get"
,
"RelativePath"
:
"api/Registration/profiles/{id}"
,
"HttpMethod"
:
"GET"
,
"IsController"
:
true
,
"Order"
:
0
,
"Parameters"
:
[
{
"Name"
:
"id"
,
"Type"
:
"System.String"
,
"IsRequired"
:
true
}
],
"ReturnTypes"
:
[
{
"Type"
:
"MMM_Server.Models.Profile"
,
"MediaTypes"
:
[
"text/plain"
,
"application/json"
,
"text/json"
],
"StatusCode"
:
200
}
]
},
{
"ContainingType"
:
"MMM_Server.Controllers.RegistrationController"
,
"Method"
:
"Update"
,
"RelativePath"
:
"api/Registration/profiles/{id}"
,
"HttpMethod"
:
"PUT"
,
"IsController"
:
true
,
"Order"
:
0
,
"Parameters"
:
[
{
"Name"
:
"id"
,
"Type"
:
"System.String"
,
"IsRequired"
:
true
},
{
"Name"
:
"updatedProfile"
,
"Type"
:
"MMM_Server.Models.Profile"
,
"IsRequired"
:
true
}
],
"ReturnTypes"
:
[]
},
{
"ContainingType"
:
"MMM_Server.Controllers.RegistrationController"
,
"Method"
:
"Delete"
,
"RelativePath"
:
"api/Registration/profiles/{id}"
,
"HttpMethod"
:
"DELETE"
,
"IsController"
:
true
,
"Order"
:
0
,
"Parameters"
:
[
{
"Name"
:
"id"
,
"Type"
:
"System.String"
,
"IsRequired"
:
true
"IsRequired"
:
true
}
}
],
],
...
...
MMM-Server/MMM-Server/obj/Debug/net8.0/MMM-Server.AssemblyInfo.cs
View file @
245a8502
...
@@ -14,7 +14,7 @@ using System.Reflection;
...
@@ -14,7 +14,7 @@ using System.Reflection;
[
assembly
:
System
.
Reflection
.
AssemblyCompanyAttribute
(
"MMM-Server"
)]
[
assembly
:
System
.
Reflection
.
AssemblyCompanyAttribute
(
"MMM-Server"
)]
[
assembly
:
System
.
Reflection
.
AssemblyConfigurationAttribute
(
"Debug"
)]
[
assembly
:
System
.
Reflection
.
AssemblyConfigurationAttribute
(
"Debug"
)]
[
assembly
:
System
.
Reflection
.
AssemblyFileVersionAttribute
(
"1.0.0.0"
)]
[
assembly
:
System
.
Reflection
.
AssemblyFileVersionAttribute
(
"1.0.0.0"
)]
[
assembly
:
System
.
Reflection
.
AssemblyInformationalVersionAttribute
(
"1.0.0+
1b8064fe62f388c9a5eddd312865292d6affd7a4
"
)]
[
assembly
:
System
.
Reflection
.
AssemblyInformationalVersionAttribute
(
"1.0.0+
74d009de2e51803bbbf37fda6d6b43394606cea7
"
)]
[
assembly
:
System
.
Reflection
.
AssemblyProductAttribute
(
"MMM-Server"
)]
[
assembly
:
System
.
Reflection
.
AssemblyProductAttribute
(
"MMM-Server"
)]
[
assembly
:
System
.
Reflection
.
AssemblyTitleAttribute
(
"MMM-Server"
)]
[
assembly
:
System
.
Reflection
.
AssemblyTitleAttribute
(
"MMM-Server"
)]
[
assembly
:
System
.
Reflection
.
AssemblyVersionAttribute
(
"1.0.0.0"
)]
[
assembly
:
System
.
Reflection
.
AssemblyVersionAttribute
(
"1.0.0.0"
)]
...
...
MMM-Server/MMM-Server/obj/Debug/net8.0/MMM-Server.AssemblyInfoInputs.cache
View file @
245a8502
45771de9efe7fc0804dee5922051ba0d2b4be37e04a63b840888622c0ed49947
70d2b9da71a0ca46e131854fd08d84da8f4ee332574b497bc72ddafa24b1af89
MMM-Server/MMM-Server/obj/Debug/net8.0/MMM-Server.csproj.CoreCompileInputs.cache
View file @
245a8502
94880d7acaa4b9506f48db68bb33584a67f669b37061b9f3b5f92c272b82b128
1e31261913ed492625f0b335bd9521ed7663f28f00dd74aba93b1c1d5fd09bd3
Prev
1
2
Next
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment