Exemplo n.º 1
0
        public IActionResult Details(string id)
        {
            var user = UserManager.Users
                       .Include(u => u.Recipes).Include(u => u.Files)
                       .Include(u => u.FavouriteRecipes)
                       .ThenInclude(fr => fr.Recipe)
                       .FirstOrDefault(u => u.Id == id);

            var profilePicture = ProfilePictureService.GetUserAvatar(user.Id);

            var path = ProfilePictureService.GetAvatarPath(profilePicture);

            if (path != null)
            {
                ViewData["AvatarPath"] = path;
            }

            var vm = new ProfileDetailsViewModel()
            {
                User           = user,
                MealCategories = Context.Categories.ToList(),
            };

            return(View("Details", vm));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> OnGetAsync()
        {
            var user = await _userManager.GetUserAsync(User);

            if (user == null)
            {
                return(NotFound($"Unable to load user with ID '{_userManager.GetUserId(User)}'."));
            }

            var email = await _userManager.GetEmailAsync(user);

            var phoneNumber = await _userManager.GetPhoneNumberAsync(user);

            var name = await _userManager.GetNameAsync(user);

            var location = await _userManager.GetLocationAsync(user);

            var gender = await _userManager.GetGenderAsync(user);

            var description = await _userManager.GetDescriptionAsync(user);

            var picture = _profilePictureService.GetUserAvatar(user.Id);

            var path = _profilePictureService.GetAvatarPath(picture);

            if (path != null)
            {
                ViewData["AvatarPath"] = path;
            }

            Input = new InputModel
            {
                Email       = email,
                PhoneNumber = phoneNumber,
                Name        = name,
                Location    = location,
                Gender      = gender,
                Description = description,
                File        = picture
            };

            IsEmailConfirmed = await _userManager.IsEmailConfirmedAsync(user);

            return(Page());
        }