Initial version
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user