36 lines
893 B
C#
36 lines
893 B
C#
|
using AGSS.Models;
|
||
|
using AGSS.Models.Entities;
|
||
|
using Microsoft.AspNetCore.Identity;
|
||
|
|
||
|
public class UserService
|
||
|
{
|
||
|
private readonly UserManager<UserModel> _userManager;
|
||
|
|
||
|
public UserService(UserManager<UserModel> userManager)
|
||
|
{
|
||
|
_userManager = userManager;
|
||
|
}
|
||
|
|
||
|
public async Task<UserProfile> GetUserProfileAsync(string userId)
|
||
|
{
|
||
|
var user = await _userManager.FindByIdAsync(userId);
|
||
|
if (user == null)
|
||
|
{
|
||
|
throw new ArgumentException("User not found");
|
||
|
}
|
||
|
|
||
|
return new UserProfile
|
||
|
{
|
||
|
Id = user.Id,
|
||
|
UserName = user.UserName,
|
||
|
Email = user.Email,
|
||
|
Sex = user.Sex,
|
||
|
Description = user.Description,
|
||
|
Config = user.Config,
|
||
|
JobCode = user.JobCode,
|
||
|
JobName = user.JobName,
|
||
|
Birthday = user.Birthday
|
||
|
};
|
||
|
}
|
||
|
}
|