From 7470da2719a404b344fec4d6b2fefd92f4ce22a5 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Fri, 7 May 2021 14:27:43 +0300 Subject: Implemented user profile page --- ExamTemplate/Web/Controllers/UserController.cs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'ExamTemplate/Web/Controllers') 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 Profile(string username) + { + UserServiceModel userServiceModel = await this._userService.GetUserByUsernameAsync(username); + + if (userServiceModel == default(UserServiceModel)) + { + return RedirectToAction("Login"); + } + + UserViewModel userViewModel = this._autoMapper.Map(userServiceModel); + + return View(userViewModel); + } } } -- cgit v1.2.3