diff options
Diffstat (limited to 'API')
| -rw-r--r-- | API/Controllers/UserController.cs | 14 | ||||
| -rw-r--r-- | API/Database/DevHiveContext.cs | 2 | ||||
| -rw-r--r-- | API/Service/UserService.cs | 12 |
3 files changed, 17 insertions, 11 deletions
diff --git a/API/Controllers/UserController.cs b/API/Controllers/UserController.cs index c2d6f2c..22555c6 100644 --- a/API/Controllers/UserController.cs +++ b/API/Controllers/UserController.cs @@ -24,14 +24,12 @@ namespace API.Controllers [HttpPost] public async Task<HttpStatusCode> Create([FromBody] UserDTO userDTO) { - HttpStatusCode returnStatusCode = await this._service.CreateUser(userDTO); - - return returnStatusCode; + return await this._service.CreateUser(userDTO); } //Read [HttpGet] - public async Task<string> GetById(int id) + public async Task<string> GetById(int id) { return await this._service.GetUserById(id); } @@ -43,7 +41,11 @@ namespace API.Controllers return await this._service.UpdateUser(id, userDTO); } - // //Delete - // [HttpDelete] + //Delete + [HttpDelete] + public async Task<HttpStatusCode> Delete(int id) + { + return await this._service.DeleteUser(id); + } } } diff --git a/API/Database/DevHiveContext.cs b/API/Database/DevHiveContext.cs index c20e9eb..4c342b5 100644 --- a/API/Database/DevHiveContext.cs +++ b/API/Database/DevHiveContext.cs @@ -6,7 +6,7 @@ using Microsoft.AspNetCore.Identity; namespace API.Database { - public class DevHiveContext : IdentityDbContext<User, IdentityRole<int>, int> + public class DevHiveContext : IdentityDbContext<User, Roles, int> { public DevHiveContext(DbContextOptions options) : base(options) { } diff --git a/API/Service/UserService.cs b/API/Service/UserService.cs index e678b17..0bc4939 100644 --- a/API/Service/UserService.cs +++ b/API/Service/UserService.cs @@ -20,24 +20,22 @@ namespace API.Service this._dbRepository = new DbRepository<User>(context); } - [HttpPost] public async Task<HttpStatusCode> CreateUser(UserDTO userDTO) { //TODO: MAKE VALIDATIONS OF PROPER REQUEST - //UserDTO newUser = JsonConvert.DeserializeObject<UserDTO>(userDTO); + + //Map UserDTO -> User //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) @@ -52,5 +50,11 @@ namespace API.Service return HttpStatusCode.OK; } + public async Task<HttpStatusCode> DeleteUser(int id) + { + await this._dbRepository.DeleteAsync(id); + + return HttpStatusCode.OK; + } } } |
