aboutsummaryrefslogtreecommitdiff
path: root/src/DevHive.Web/Controllers/UserController.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/DevHive.Web/Controllers/UserController.cs')
-rw-r--r--src/DevHive.Web/Controllers/UserController.cs28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/DevHive.Web/Controllers/UserController.cs b/src/DevHive.Web/Controllers/UserController.cs
index b23fdee..ad2656c 100644
--- a/src/DevHive.Web/Controllers/UserController.cs
+++ b/src/DevHive.Web/Controllers/UserController.cs
@@ -9,6 +9,7 @@ using DevHive.Web.Models.Identity.User;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using DevHive.Common.Models.Identity;
+using DevHive.Common.Models;
namespace DevHive.Web.Controllers
{
@@ -53,6 +54,15 @@ namespace DevHive.Web.Controllers
return new CreatedResult("Register", tokenWebModel);
}
+ [HttpPost]
+ [Route("AddAFriend")]
+ public async Task<IActionResult> AddAFriend(Guid userId, [FromBody] IdModel friendIdModel)
+ {
+ return await this._userService.AddFriend(userId, friendIdModel.Id) ?
+ new OkResult() :
+ new BadRequestResult();
+ }
+
//Read
[HttpGet]
public async Task<IActionResult> GetById(Guid id, [FromHeader] string authorization)
@@ -66,6 +76,16 @@ namespace DevHive.Web.Controllers
return new OkObjectResult(userWebModel);
}
+ [HttpGet]
+ [Route("GetAFriend")]
+ public async Task<IActionResult> GetAFriend(Guid friendId)
+ {
+ UserServiceModel friendServiceModel = await this._userService.GetFriendById(friendId);
+ UserWebModel friend = this._userMapper.Map<UserWebModel>(friendServiceModel);
+
+ return new OkObjectResult(friend);
+ }
+
//Update
[HttpPut]
public async Task<IActionResult> Update(Guid id, [FromBody] UpdateUserWebModel updateModel, [FromHeader] string authorization)
@@ -93,5 +113,13 @@ namespace DevHive.Web.Controllers
await this._userService.DeleteUser(id);
return new OkResult();
}
+
+ [HttpDelete]
+ [Route("RemoveAFriend")]
+ public async Task<IActionResult> RemoveAFriend(Guid userId, Guid friendId)
+ {
+ await this._userService.RemoveFriend(userId, friendId);
+ return new OkResult();
+ }
}
}