diff options
| author | transtrike <transtrike@gmail.com> | 2020-12-19 15:47:01 +0200 |
|---|---|---|
| committer | transtrike <transtrike@gmail.com> | 2020-12-19 15:47:01 +0200 |
| commit | fa09c0cc6cf99034dcc1301692ccb4d019087213 (patch) | |
| tree | a5d453243884a315e061ef7e3723fbf7bb68d43f /src/DevHive.Web/Controllers | |
| parent | 3fc676497f4a4b1671e31cc3b8cd3e4c6ac96920 (diff) | |
| download | DevHive-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')
| -rw-r--r-- | src/DevHive.Web/Controllers/FriendsController.cs | 59 | ||||
| -rw-r--r-- | src/DevHive.Web/Controllers/UserController.cs | 28 |
2 files changed, 28 insertions, 59 deletions
diff --git a/src/DevHive.Web/Controllers/FriendsController.cs b/src/DevHive.Web/Controllers/FriendsController.cs deleted file mode 100644 index 1b9b9c5..0000000 --- a/src/DevHive.Web/Controllers/FriendsController.cs +++ /dev/null @@ -1,59 +0,0 @@ -using System; -using System.Threading.Tasks; -using AutoMapper; -using DevHive.Common.Models; -using DevHive.Data.Repositories; -using DevHive.Services.Models.Identity.User; -using DevHive.Services.Options; -using DevHive.Services.Services; -using DevHive.Web.Models.Identity.User; -using Microsoft.AspNetCore.Authorization; -using Microsoft.AspNetCore.Mvc; - -namespace DevHive.Web.Controllers -{ - [ApiController] - [Route("/api")] - [Authorize(Roles = "User")] - public class FriendsController - { - private readonly FriendsService _friendsService; - private readonly IMapper _friendsMapper; - - public FriendsController(FriendsService friendsService, IMapper mapper) - { - this._friendsService = friendsService; - this._friendsMapper = mapper; - } - - //Create - [HttpPost] - [Route("AddAFriend")] - public async Task<IActionResult> AddAFriend(Guid userId, [FromBody] IdModel friendIdModel) - { - return await this._friendsService.AddFriend(userId, friendIdModel.Id) ? - new OkResult() : - new BadRequestResult(); - } - - //Read - [HttpGet] - [Route("GetAFriend")] - public async Task<IActionResult> GetAFriend(Guid friendId) - { - UserServiceModel friendServiceModel = await this._friendsService.GetFriendById(friendId); - UserWebModel friend = this._friendsMapper.Map<UserWebModel>(friendServiceModel); - - return new OkObjectResult(friend); - } - - //Delete - [HttpDelete] - [Route("RemoveAFriend")] - public async Task<IActionResult> RemoveAFriend(Guid userId, Guid friendId) - { - await this._friendsService.RemoveFriend(userId, friendId); - return new OkResult(); - } - } -}
\ No newline at end of file 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(); + } } } |
