aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortranstrike <transtrike@gmail.com>2020-12-15 19:39:00 +0200
committertranstrike <transtrike@gmail.com>2020-12-15 19:39:00 +0200
commit85b41def10318ff04e72991008ba7d0e623a7674 (patch)
treeb23c4f15989c99110e7fd9dd9b006ac91fbfc1cf
parent54d081a513117c732ab4d62312b440d37dfe0d67 (diff)
parent9b547cb43ec6a3d28d4f35cef15ac90e465aa695 (diff)
downloadDevHive-85b41def10318ff04e72991008ba7d0e623a7674.tar
DevHive-85b41def10318ff04e72991008ba7d0e623a7674.tar.gz
DevHive-85b41def10318ff04e72991008ba7d0e623a7674.zip
Merge branch 'dev' of github.com:Team-Kaleidoscope/DevHive into dev
-rw-r--r--src/DevHive.Data/Models/Role.cs10
-rw-r--r--src/DevHive.Data/Repositories/RoleRepository.cs33
-rw-r--r--src/DevHive.Services/Configurations/Mapping/RoleMapings.cs14
-rw-r--r--src/DevHive.Web/Configurations/Extensions/ConfigureDatabase.cs2
-rw-r--r--src/DevHive.Web/Controllers/RoleController.cs8
5 files changed, 64 insertions, 3 deletions
diff --git a/src/DevHive.Data/Models/Role.cs b/src/DevHive.Data/Models/Role.cs
new file mode 100644
index 0000000..974add1
--- /dev/null
+++ b/src/DevHive.Data/Models/Role.cs
@@ -0,0 +1,10 @@
+using System;
+using Microsoft.AspNetCore.Identity;
+using System.ComponentModel.DataAnnotations.Schema;
+
+namespace DevHive.Data.Models
+{
+ [Table("Roles")]
+ public class Role : IdentityRole<Guid>
+ { }
+}
diff --git a/src/DevHive.Data/Repositories/RoleRepository.cs b/src/DevHive.Data/Repositories/RoleRepository.cs
new file mode 100644
index 0000000..5ddadab
--- /dev/null
+++ b/src/DevHive.Data/Repositories/RoleRepository.cs
@@ -0,0 +1,33 @@
+using System;
+using System.Threading.Tasks;
+using Data.Models.Interfaces.Database;
+using DevHive.Data.Models;
+
+namespace DevHive.Data.Repositories
+{
+ public class RoleRepository : IRepository<Role>
+ {
+ public async Task AddAsync(Role entity)
+ {
+ throw new NotImplementedException();
+ }
+
+ //Find entity by id
+ public async Task<TEntity> GetByIdAsync(Guid id)
+ {
+ throw new NotImplementedException();
+ }
+
+ //Modify Entity from database
+ public async Task EditAsync(Role newEntity)
+ {
+ throw new NotImplementedException();
+ }
+
+ //Delete Entity from database
+ public async Task DeleteAsync(Role entity)
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
diff --git a/src/DevHive.Services/Configurations/Mapping/RoleMapings.cs b/src/DevHive.Services/Configurations/Mapping/RoleMapings.cs
new file mode 100644
index 0000000..0e06523
--- /dev/null
+++ b/src/DevHive.Services/Configurations/Mapping/RoleMapings.cs
@@ -0,0 +1,14 @@
+using DevHive.Data.Models;
+using AutoMapper;
+using DevHive.Services.Models.Identity.Role;
+
+namespace DevHive.Services.Configurations.Mapping
+{
+ public class RoleMappings : Profile
+ {
+ public RoleMappings()
+ {
+ CreateMap<RoleServiceModel, Role>();
+ }
+ }
+}
diff --git a/src/DevHive.Web/Configurations/Extensions/ConfigureDatabase.cs b/src/DevHive.Web/Configurations/Extensions/ConfigureDatabase.cs
index f877e6c..0bd66a6 100644
--- a/src/DevHive.Web/Configurations/Extensions/ConfigureDatabase.cs
+++ b/src/DevHive.Web/Configurations/Extensions/ConfigureDatabase.cs
@@ -16,7 +16,7 @@ namespace DevHive.Web.Configurations.Extensions
services.AddDbContext<DevHiveContext>(options =>
options.UseNpgsql(configuration.GetConnectionString("DEV")));
- services.AddIdentity<User, IdentityRole>()
+ services.AddIdentity<User, Role>()
.AddEntityFrameworkStores<DevHiveContext>();
services.Configure<IdentityOptions>(options =>
diff --git a/src/DevHive.Web/Controllers/RoleController.cs b/src/DevHive.Web/Controllers/RoleController.cs
index e39d858..5e73357 100644
--- a/src/DevHive.Web/Controllers/RoleController.cs
+++ b/src/DevHive.Web/Controllers/RoleController.cs
@@ -24,7 +24,9 @@ namespace DevHive.Web.Controllers
[HttpPost]
public Task<IActionResult> Create(CreateRoleWebModel createRoleWebModel)
{
- RoleServiceModel roleServiceModel = this._roleMapper.Map<RoleServiceModel>(createRoleWebModel);
+ RoleServiceModel roleServiceModel =
+ this._roleMapper.Map<RoleServiceModel>(createRoleWebModel);
+
return this._service.CreateRole(roleServiceModel);
}
@@ -37,7 +39,9 @@ namespace DevHive.Web.Controllers
[HttpPut]
public Task<IActionResult> Update(UpdateRoleWebModel updateRoleWebModel)
{
- RoleServiceModel roleServiceModel = this._roleMapper.Map<RoleServiceModel>(updateRoleWebModel);
+ RoleServiceModel roleServiceModel =
+ this._roleMapper.Map<RoleServiceModel>(updateRoleWebModel);
+
return this._service.UpdateRole(roleServiceModel);
}