aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--API/Controllers/UserController.cs16
-rw-r--r--API/Service/UserService.cs25
-rw-r--r--Models/Classes/User.cs2
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.