Academatica.Api/Academatica.Api.Users/Controllers/UsersController.cs
/// <summary>
/// Endpoint used to get user profile information (username, profile pic URL, first name, last name, 
/// experience points, exp points this week, level, exp until the next level).
/// </summary>
/// <param name="id">User ID.</param>
Endpoint used to get user profile information (username, profile pic URL, first name, last name,
experience points, exp points this week, level, exp until the next level).
Endpoint used to get user profile information ( username profile pic URL first name last name experience points exp points this week level exp until the next level ) .
[HttpGet]
        [Route("{id}")]
        public async Task<IActionResult> GetUserProfile(Guid id)
        {
            var user = await _userManager.FindByIdAsync(id.ToString());
            if (user == null)
            {
                return NotFound("Invalid user ID.");
            }
            var userStats = _academaticaDbContext.UserStats.Where(x => x.UserId == id).FirstOrDefault();
            if (userStats == null)
            {
                return NotFound("Stats entry could not be found.");
            }
            return Ok(new GetUserProfileResponseDto()
            {
                Email = user.Email,
                Username = user.UserName,
                ProfilePicUrl = user.ProfilePicUrl,
                FirstName = user.FirstName,
                LastName = user.LastName,
                Exp = userStats.UserExp,
                ExpThisWeek = userStats.UserExpThisWeek
            });
        }
[ HttpGet ] [ Route ( " " ) ] public async Task < IActionResult > GetUserProfile ( Guid id ) { var user = await _userManager . FindByIdAsync ( id . ToString ( ) ) ; if ( user == null ) { return NotFound ( " " ) ; } var userStats = _academaticaDbContext . UserStats . Where ( x => x . UserId == id ) . FirstOrDefault ( ) ; if ( userStats == null ) { return NotFound ( " " ) ; } return Ok ( new GetUserProfileResponseDto ( ) { Email = user . Email , Username = user . UserName , ProfilePicUrl = user . ProfilePicUrl , FirstName = user . FirstName , LastName = user . LastName , Exp = userStats . UserExp , ExpThisWeek = userStats . UserExpThisWeek } ) ; }
Endpoint used to get user profile information (username, profile pic URL, first name, last name,
experience points, exp points this week, level, exp until the next level).
Endpoint used to get user profile information ( username profile pic URL first name last name experience points exp points this week level exp until the next level ) .
id
Guid
None