diff --git a/exercise.wwwapi/DTOs/UserDTO.cs b/exercise.wwwapi/DTOs/UserDTO.cs index c2f3e15..a02d96b 100644 --- a/exercise.wwwapi/DTOs/UserDTO.cs +++ b/exercise.wwwapi/DTOs/UserDTO.cs @@ -1,14 +1,21 @@ -namespace exercise.wwwapi.DTOs +using exercise.wwwapi.Models; +using System.ComponentModel.DataAnnotations.Schema; + +namespace exercise.wwwapi.DTOs { public class UserDTO { - public int id { get; set; } - public string email { get; set; } - public string password { get; set; } - public string? firstName { get; set; } - public string? lastName { get; set; } - public string? bio { get; set; } - public string? githubUsername { get; set; } - public string? username { get; set; } + public string? Username { get; set; } + public string? Email { get; set; } + public string? FirstName { get; set; } + public string? LastName { get; set; } + public string? GithubUsername { get; set; } + public string? Mobile { get; set; } + public Roles? Role { get; set; } + public string? Specialism { get; set; } + public string? Bio { get; set; } + public DateTime? StartDate { get; set; } + public DateTime? EndDate { get; set; } + public string? Photo { get; set; } } } diff --git a/exercise.wwwapi/Endpoints/UserEndpoints.cs b/exercise.wwwapi/Endpoints/UserEndpoints.cs index 1f96a03..391f843 100644 --- a/exercise.wwwapi/Endpoints/UserEndpoints.cs +++ b/exercise.wwwapi/Endpoints/UserEndpoints.cs @@ -83,7 +83,7 @@ private static IResult Register(RegisterRequestDTO request, IRepository se Data = mapper.Map(user) }; - return Results.Created($"/users/{response.Data.id}", response.Data); + return Results.Created($"/users/{user.Id}", response); } [ProducesResponseType(StatusCodes.Status200OK)] @@ -132,11 +132,18 @@ private static IResult Login(LoginRequestDTO request, IRepository service, } [ProducesResponseType(StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status404NotFound)] - public static async Task GetUserById(IRepository service, int id) + public static async Task GetUserById(IRepository service, int id, IMapper mapper) { var user = service.GetById(id); if (user == null) return TypedResults.NotFound(); - return TypedResults.Ok(user); + + ResponseDTO response = new ResponseDTO + { + Message = "success", + Data = mapper.Map(user) + }; + + return TypedResults.Ok(response); } [ProducesResponseType(StatusCodes.Status200OK)]