diff options
| author | Syndamia <kamen.d.mladenov@protonmail.com> | 2021-05-07 14:27:43 +0300 |
|---|---|---|
| committer | Syndamia <kamen.d.mladenov@protonmail.com> | 2021-05-07 14:27:43 +0300 |
| commit | 7470da2719a404b344fec4d6b2fefd92f4ce22a5 (patch) | |
| tree | 2fd27618625fb58c238c468139f37a43731d6ac5 /ExamTemplate/Web/Controllers/UserController.cs | |
| parent | 380f4d5d6120dcdb36e904aae98dd2e24db8a974 (diff) | |
| download | it-kariera-exam-template-7470da2719a404b344fec4d6b2fefd92f4ce22a5.tar it-kariera-exam-template-7470da2719a404b344fec4d6b2fefd92f4ce22a5.tar.gz it-kariera-exam-template-7470da2719a404b344fec4d6b2fefd92f4ce22a5.zip | |
Implemented user profile page
Diffstat (limited to 'ExamTemplate/Web/Controllers/UserController.cs')
| -rw-r--r-- | ExamTemplate/Web/Controllers/UserController.cs | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/ExamTemplate/Web/Controllers/UserController.cs b/ExamTemplate/Web/Controllers/UserController.cs index 622a616..4a9cf31 100644 --- a/ExamTemplate/Web/Controllers/UserController.cs +++ b/ExamTemplate/Web/Controllers/UserController.cs @@ -7,7 +7,7 @@ using System.Threading.Tasks; namespace ExamTemplate.Web.Controllers { - public class UserController : Controller + public class UserController : Controller { private readonly IMapper _autoMapper; private readonly UserService _userService; @@ -73,5 +73,21 @@ namespace ExamTemplate.Web.Controllers return RedirectToAction("Login"); } + + [HttpGet] + [Route("/Profile/{username}")] + public async Task<IActionResult> Profile(string username) + { + UserServiceModel userServiceModel = await this._userService.GetUserByUsernameAsync(username); + + if (userServiceModel == default(UserServiceModel)) + { + return RedirectToAction("Login"); + } + + UserViewModel userViewModel = this._autoMapper.Map<UserViewModel>(userServiceModel); + + return View(userViewModel); + } } } |
