mirror of
https://github.com/aaronpo97/the-biergarten-app.git
synced 2026-02-16 10:42:08 +00:00
Update repository, seed and service layers
This commit is contained in:
@@ -1,15 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace BusinessLayer.Services
|
||||
{
|
||||
public interface IService<T>
|
||||
where T : class
|
||||
{
|
||||
IEnumerable<T> GetAll(int? limit, int? offset);
|
||||
T? GetById(Guid id);
|
||||
void Add(T entity);
|
||||
void Update(T entity);
|
||||
void Delete(Guid id);
|
||||
}
|
||||
}
|
||||
@@ -2,9 +2,9 @@ using DataAccessLayer.Entities;
|
||||
|
||||
namespace BusinessLayer.Services
|
||||
{
|
||||
public interface IUserService : IService<UserAccount>
|
||||
public interface IUserService
|
||||
{
|
||||
UserAccount? GetByUsername(string username);
|
||||
UserAccount? GetByEmail(string email);
|
||||
Task<IEnumerable<UserAccount>> GetAllAsync(int? limit = null, int? offset = null);
|
||||
Task<UserAccount?> GetByIdAsync(Guid id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,51 +1,18 @@
|
||||
using DataAccessLayer;
|
||||
using DataAccessLayer.Entities;
|
||||
using DataAccessLayer.Repositories;
|
||||
|
||||
namespace BusinessLayer.Services
|
||||
{
|
||||
public class UserService : IUserService
|
||||
public class UserService(IUserAccountRepository repository) : IUserService
|
||||
{
|
||||
private readonly IUserAccountRepository _userAccountRepository;
|
||||
|
||||
public UserService(IUserAccountRepository userAccountRepository)
|
||||
public async Task<IEnumerable<UserAccount>> GetAllAsync(int? limit = null, int? offset = null)
|
||||
{
|
||||
_userAccountRepository = userAccountRepository;
|
||||
return await repository.GetAll(limit, offset);
|
||||
}
|
||||
|
||||
public IEnumerable<UserAccount> GetAll(int? limit, int? offset)
|
||||
public async Task<UserAccount?> GetByIdAsync(Guid id)
|
||||
{
|
||||
return _userAccountRepository.GetAll(limit, offset);
|
||||
}
|
||||
|
||||
public UserAccount? GetById(Guid id)
|
||||
{
|
||||
return _userAccountRepository.GetById(id);
|
||||
}
|
||||
|
||||
public UserAccount? GetByUsername(string username)
|
||||
{
|
||||
return _userAccountRepository.GetByUsername(username);
|
||||
}
|
||||
|
||||
public UserAccount? GetByEmail(string email)
|
||||
{
|
||||
return _userAccountRepository.GetByEmail(email);
|
||||
}
|
||||
|
||||
public void Add(UserAccount userAccount)
|
||||
{
|
||||
_userAccountRepository.Add(userAccount);
|
||||
}
|
||||
|
||||
public void Update(UserAccount userAccount)
|
||||
{
|
||||
_userAccountRepository.Update(userAccount);
|
||||
}
|
||||
|
||||
public void Delete(Guid id)
|
||||
{
|
||||
_userAccountRepository.Delete(id);
|
||||
return await repository.GetById(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user