From fa09c0cc6cf99034dcc1301692ccb4d019087213 Mon Sep 17 00:00:00 2001 From: transtrike Date: Sat, 19 Dec 2020 15:47:01 +0200 Subject: Moved Friends to User(you no longer have friends) --- src/DevHive.Web/Controllers/UserController.cs | 28 +++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'src/DevHive.Web/Controllers/UserController.cs') 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 AddAFriend(Guid userId, [FromBody] IdModel friendIdModel) + { + return await this._userService.AddFriend(userId, friendIdModel.Id) ? + new OkResult() : + new BadRequestResult(); + } + //Read [HttpGet] public async Task GetById(Guid id, [FromHeader] string authorization) @@ -66,6 +76,16 @@ namespace DevHive.Web.Controllers return new OkObjectResult(userWebModel); } + [HttpGet] + [Route("GetAFriend")] + public async Task GetAFriend(Guid friendId) + { + UserServiceModel friendServiceModel = await this._userService.GetFriendById(friendId); + UserWebModel friend = this._userMapper.Map(friendServiceModel); + + return new OkObjectResult(friend); + } + //Update [HttpPut] public async Task 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 RemoveAFriend(Guid userId, Guid friendId) + { + await this._userService.RemoveFriend(userId, friendId); + return new OkResult(); + } } } -- cgit v1.2.3