Ejemplo n.º 1
0
        public async Task <IActionResult> GetCurrentUser()
        {
            var authContext = this.GetAuthContext();

            if (authContext.UserType != UserType.User || !authContext.User.HasValue)
            {
                return(Unauthorized());
            }

            var user  = authContext.User.Value;
            var votes = await reviews.FetchUserVenueVotes(user.UserId)
                        .Ensure(r => r.HasValue, "Reviews found")
                        .OnSuccess(r => r.Value)
                        .OnBoth(r => r.IsSuccess ? r.Value : new List <int>())
                        .ConfigureAwait(false);

            return(Ok(new DtoUserProfile
            {
                RegistrationId = user.RegistrationId,
                VotedVenueIds = votes,
                WantAdvertising = user.WantAdvertising,
                FirstName = user.FirstName,
                LastName = user.LastName
            }));
        }