aboutsummaryrefslogtreecommitdiff
path: root/src/DevHive.Web
diff options
context:
space:
mode:
authortranstrike <transtrike@gmail.com>2020-12-15 19:38:50 +0200
committertranstrike <transtrike@gmail.com>2020-12-15 19:38:50 +0200
commit54d081a513117c732ab4d62312b440d37dfe0d67 (patch)
treeef90a2aefca9da180d71d92256a2b51b91ad65ff /src/DevHive.Web
parent15b69b3036ba6a36ed0de8a64f466c9f46d7f0e9 (diff)
downloadDevHive-54d081a513117c732ab4d62312b440d37dfe0d67.tar
DevHive-54d081a513117c732ab4d62312b440d37dfe0d67.tar.gz
DevHive-54d081a513117c732ab4d62312b440d37dfe0d67.zip
User Controller, Service & Data implemented
Diffstat (limited to 'src/DevHive.Web')
-rw-r--r--src/DevHive.Web/Configurations/Mapping/UserMappings.cs9
-rw-r--r--src/DevHive.Web/Controllers/UserController.cs31
-rw-r--r--src/DevHive.Web/appsettings.json7
3 files changed, 29 insertions, 18 deletions
diff --git a/src/DevHive.Web/Configurations/Mapping/UserMappings.cs b/src/DevHive.Web/Configurations/Mapping/UserMappings.cs
index f3daf5a..2964a00 100644
--- a/src/DevHive.Web/Configurations/Mapping/UserMappings.cs
+++ b/src/DevHive.Web/Configurations/Mapping/UserMappings.cs
@@ -1,6 +1,7 @@
using DevHive.Data.Models;
using AutoMapper;
-using DevHive.Services.Models.Identity;
+using DevHive.Services.Models.Identity.User;
+using DevHive.Web.Models.Identity.User;
namespace DevHive.Web.Configurations.Mapping
{
@@ -8,9 +9,9 @@ namespace DevHive.Web.Configurations.Mapping
{
public UserMappings()
{
- CreateMap<UserServiceModel, User>();
- CreateMap<RegisterServiceModel, User>();
- CreateMap<UpdateUserServiceModel, User>();
+ CreateMap<LoginWebModel, LoginServiceModel>();
+ CreateMap<LoginWebModel, LoginServiceModel>();
+ CreateMap<UpdateUserWebModel, UpdateUserServiceModel>();
}
}
}
diff --git a/src/DevHive.Web/Controllers/UserController.cs b/src/DevHive.Web/Controllers/UserController.cs
index 14ecb73..480fbe4 100644
--- a/src/DevHive.Web/Controllers/UserController.cs
+++ b/src/DevHive.Web/Controllers/UserController.cs
@@ -2,6 +2,7 @@ using System;
using System.Threading.Tasks;
using AutoMapper;
using DevHive.Data.Repositories;
+using DevHive.Services.Models.Identity.User;
using DevHive.Services.Options;
using DevHive.Services.Services;
using DevHive.Web.Models.Identity.User;
@@ -15,44 +16,47 @@ namespace DevHive.Web.Controllers
public class UserController: ControllerBase
{
private readonly UserService _service;
+ private readonly IMapper _userMapper;
public UserController(DevHiveContext context, IMapper mapper, JWTOptions jwtOptions)
{
this._service = new UserService(context, mapper, jwtOptions);
+ this._userMapper = mapper;
}
[HttpPost]
[Route("Login")]
- public async Task<IActionResult> Login([FromBody] LoginWebModel loginWebModel)
+ public async Task<IActionResult> Login([FromBody] LoginWebModel loginModel)
{
- var loginDTO =
- return await this._service.LoginUser(loginDTO);
- //throw new NotImplementedException();
+ LoginServiceModel loginServiceModel = this._userMapper.Map<LoginServiceModel>(loginModel);
+
+ return await this._service.LoginUser(loginServiceModel);
}
[HttpPost]
[Route("Register")]
- public async Task<IActionResult> Register([FromBody] RegisterWebModel registerWebModel)
+ public async Task<IActionResult> Register([FromBody] RegisterWebModel registerModel)
{
- //return await this._service.RegisterUser(registerDto);
- throw new NotImplementedException();
+ RegisterServiceModel registerServiceModel = this._userMapper.Map<RegisterServiceModel>(registerModel);
+
+ return await this._service.RegisterUser(registerServiceModel);
}
//Read
[HttpGet]
public async Task<IActionResult> GetById(Guid id)
{
- //return await this._service.GetUserById(id);
- throw new NotImplementedException();
+ return await this._service.GetUserById(id);
}
//Update
[HttpPut]
[Authorize]
- public async Task<IActionResult> Update(Guid id, [FromBody] UpdateUserWebModel updateUserWebModel)
+ public async Task<IActionResult> Update(Guid id, [FromBody] UpdateUserWebModel updateModel)
{
- //return await this._service.UpdateUser(id, userDTO);
- throw new NotImplementedException();
+ UpdateUserServiceModel updateUserServiceModel = this._userMapper.Map<UpdateUserServiceModel>(updateModel);
+
+ return await this._service.UpdateUser(id, updateUserServiceModel);
}
//Delete
@@ -60,8 +64,7 @@ namespace DevHive.Web.Controllers
[Authorize]
public async Task<IActionResult> Delete(Guid id)
{
- //return await this._service.DeleteUser(id);
- throw new NotImplementedException();
+ return await this._service.DeleteUser(id);
}
}
}
diff --git a/src/DevHive.Web/appsettings.json b/src/DevHive.Web/appsettings.json
index 289208b..b0c8a57 100644
--- a/src/DevHive.Web/appsettings.json
+++ b/src/DevHive.Web/appsettings.json
@@ -4,5 +4,12 @@
},
"ConnectionStrings" : {
"DEV": "Server=localhost;Port=5432;Database=API;User Id=postgres;Password=;"
+ },
+ "Logging" : {
+ "LogLevel" : {
+ "Default" : "Information",
+ "Microsoft" : "Warning",
+ "Microsoft.Hosting.Lifetime" : "Information"
+ }
}
}