Esempio n. 1
0
        public async Task <IActionResult> Profile(string userId)
        {
            ApplicationUser user;

            if (!string.IsNullOrEmpty(userId) && User.IsInRole("Admin"))
            {
                user = await _userManager.FindByIdAsync(userId);
            }
            else
            {
                user = await _userManager.GetUserAsync(User);
            }

            var roles = await _userManager.GetRolesAsync(user);

            if (user != null)
            {
                var model = _mapper.ApplicationUserToAccountProfileModel(user, _orderService, roles.FirstOrDefault());
                return(View(model));
            }

            return(RedirectToAction("Index", "Home"));
        }