aboutsummaryrefslogtreecommitdiff
path: root/src/DevHive.Web/Controllers/UserController.cs
diff options
context:
space:
mode:
authortranstrike <transtrike@gmail.com>2020-12-19 15:47:01 +0200
committertranstrike <transtrike@gmail.com>2020-12-19 15:47:01 +0200
commitfa09c0cc6cf99034dcc1301692ccb4d019087213 (patch)
treea5d453243884a315e061ef7e3723fbf7bb68d43f /src/DevHive.Web/Controllers/UserController.cs
parent3fc676497f4a4b1671e31cc3b8cd3e4c6ac96920 (diff)
downloadDevHive-fa09c0cc6cf99034dcc1301692ccb4d019087213.tar
DevHive-fa09c0cc6cf99034dcc1301692ccb4d019087213.tar.gz
DevHive-fa09c0cc6cf99034dcc1301692ccb4d019087213.zip
Moved Friends to User(you no longer have friends)
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();
+ }
}
}