diff options
Diffstat (limited to 'API')
| -rw-r--r-- | API/Controllers/UserController.cs | 16 | ||||
| -rw-r--r-- | API/Service/UserService.cs | 25 |
2 files changed, 36 insertions, 5 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 +} |
