diff options
| author | transtrike <transtrike@gmail.com> | 2020-12-10 13:46:38 +0200 |
|---|---|---|
| committer | transtrike <transtrike@gmail.com> | 2020-12-10 13:46:38 +0200 |
| commit | b22378ffd9c0d8be101cd20fdfa121cce4e915e2 (patch) | |
| tree | 0561b34feb63331e668290e0460fdd01eea36eb1 | |
| parent | f50957985300c3bfc6ae5564d7eaa67e099ca8f2 (diff) | |
| parent | 7a262ddb5c9b14250e7cdfaf4cb8f9f197bf381d (diff) | |
| download | DevHive-b22378ffd9c0d8be101cd20fdfa121cce4e915e2.tar DevHive-b22378ffd9c0d8be101cd20fdfa121cce4e915e2.tar.gz DevHive-b22378ffd9c0d8be101cd20fdfa121cce4e915e2.zip | |
Merge branch 'dev' of github.com:team-kaleidoscope/DevHive into dev
| -rw-r--r-- | API/Controllers/UserController.cs | 16 | ||||
| -rw-r--r-- | API/Service/UserService.cs | 25 | ||||
| -rw-r--r-- | Models/Classes/User.cs | 2 |
3 files changed, 37 insertions, 6 deletions
diff --git a/API/Controllers/UserController.cs b/API/Controllers/UserController.cs index b3da7fc..c2d6f2c 100644 --- a/API/Controllers/UserController.cs +++ b/API/Controllers/UserController.cs @@ -30,12 +30,20 @@ namespace API.Controllers } //Read - // [HttpGet] + [HttpGet] + public async Task<string> GetById(int id) + { + return await this._service.GetUserById(id); + } - // //Update - // [HttpPut] + //Update + [HttpPut] + public async Task<HttpStatusCode> Update(int id, [FromBody] UserDTO userDTO) + { + return await this._service.UpdateUser(id, userDTO); + } // //Delete // [HttpDelete] } -}
\ No newline at end of file +} diff --git a/API/Service/UserService.cs b/API/Service/UserService.cs index a2d671a..e678b17 100644 --- a/API/Service/UserService.cs +++ b/API/Service/UserService.cs @@ -29,5 +29,28 @@ namespace API.Service //await this._dbRepository.AddAsync(newUser); return HttpStatusCode.OK; } + + [HttpGet] + public async Task<string> GetUserById(int id) + { + User user = await this._dbRepository.FindByIdAsync(id); + return JsonConvert.SerializeObject(user); + } + + [HttpPut] + public async Task<HttpStatusCode> UpdateUser(int id, UserDTO userDTO) + { + // TODO: add mapper (UserDTO to User) + User user = new User{ + Id = id, + FirstName = "Misho", + LastName = "Mishov", + UserName = "cheese" + }; + await this._dbRepository.EditAsync(id, user); + + return HttpStatusCode.OK; + } + } -}
\ No newline at end of file +} diff --git a/Models/Classes/User.cs b/Models/Classes/User.cs index e5a83d6..72ecb26 100644 --- a/Models/Classes/User.cs +++ b/Models/Classes/User.cs @@ -60,7 +60,7 @@ namespace Models.Classes } } - public List<User> Friends { get; set; } + // public List<User> Friends { get; set; } /// <summary> /// Throws an argument exception if the given value is not composed only of letters, and if specified, also of digits. |
