Exemplo n.º 1
0
        public async Task <IActionResult> Profile()
        {
            var userId = User.FindFirstValue(ClaimTypes.NameIdentifier);

            if (string.IsNullOrEmpty(userId))
            {
                return(Redirect("/Identity/Account/Login%2FMy%2FProfile"));
            }

            UserInfoTableModel     userInfo       = (await _usersInfoRepository.spGetUserInfo_ByUserId(userId)) ?? new UserInfoTableModel();
            List <EventTableModel> lastFiveEvents = await _eventsRepository.GetLastFiveEvents_ByUserId(userId);

            List <spGetNotEmptyValueWallet_ByUserIdResult> notEmptyWallets = await _walletsRepository.GetNotEmptyWalletsByUserIdAsync(userId);

            var user = await _usersManager.FindByIdAsync(userId);

            var model = new ProfileViewModel()
            {
                Email           = user.Email,
                Username        = user.UserName,
                PhoneNumber     = user.PhoneNumber,
                UserInfo        = userInfo,
                LastFiveEvents  = lastFiveEvents,
                NotEmptyWallets = notEmptyWallets,
                IsMyProfile     = true
            };

            return(View(model));
        }
Exemplo n.º 2
0
    public async Task <ActionResult> Profile(string username)
    {
        var user = await _usersManager.FindByNameAsync(username);

        var userId = User.FindFirstValue(ClaimTypes.NameIdentifier);

        if (user != null)
        {
            UserInfoTableModel     userInfo       = (await _usersInfoRepository.spGetUserInfo_ByUserId(user.Id)) ?? new UserInfoTableModel();
            List <EventTableModel> lastFiveEvents = await _eventsRepository.GetLastFiveEvents_ByUserId(user.Id);

            List <spGetNotEmptyValueWallet_ByUserIdResult> notEmptyWallets = await _walletsRepository.GetNotEmptyWalletsByUserIdAsync(user.Id);

            var model = new ProfileViewModel()
            {
                Email           = user.Email,
                Username        = user.UserName,
                PhoneNumber     = user.PhoneNumber,
                UserInfo        = userInfo,
                LastFiveEvents  = lastFiveEvents,
                NotEmptyWallets = notEmptyWallets,
                IsMyProfile     = userId == user.Id
            };

            return(View("~/Views/Users/Profile.cshtml", model));
        }

        return(View("~/Views/Users/UserNotExists.cshtml"));
    }