34 lines
850 B
C#
34 lines
850 B
C#
using EonaCat.gRPC.Core.Entities;
|
|
using EonaCat.gRPC.Core.Interfaces.Repositories;
|
|
using EonaCat.gRPC.Core.Interfaces.Services;
|
|
|
|
namespace EonaCat.gRPC.Service;
|
|
|
|
public class UserService : IUserService
|
|
{
|
|
private readonly IUserRepository _userRepository;
|
|
|
|
public UserService(IUserRepository userRepository)
|
|
{
|
|
_userRepository = userRepository;
|
|
}
|
|
|
|
public async Task<long> CreateUser(UserEntity user)
|
|
{
|
|
await _userRepository.AddAsync(user);
|
|
await _userRepository.SaveChangesAsync();
|
|
return user.Id;
|
|
}
|
|
|
|
public async Task<IEnumerable<UserEntity>> GetAsync()
|
|
{
|
|
var users = await _userRepository.ListAsync();
|
|
return users;
|
|
}
|
|
|
|
public async Task<UserEntity> GetAsync(long id)
|
|
{
|
|
var user = await _userRepository.GetAsync(id);
|
|
return user;
|
|
}
|
|
} |