diff options
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); + } } } |
