mirror of
https://github.com/aaronpo97/the-biergarten-app.git
synced 2026-02-16 20:13:49 +00:00
Refactor data layer, add business layer
This commit is contained in:
@@ -4,4 +4,8 @@
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="../DataAccessLayer/DataAccessLayer.csproj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
||||
15
BusinessLayer/Services/IService.cs
Normal file
15
BusinessLayer/Services/IService.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
10
BusinessLayer/Services/IUserService.cs
Normal file
10
BusinessLayer/Services/IUserService.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
using DataAccessLayer.Entities;
|
||||
|
||||
namespace BusinessLayer.Services
|
||||
{
|
||||
public interface IUserService : IService<UserAccount>
|
||||
{
|
||||
UserAccount? GetByUsername(string username);
|
||||
UserAccount? GetByEmail(string email);
|
||||
}
|
||||
}
|
||||
50
BusinessLayer/Services/UserService.cs
Normal file
50
BusinessLayer/Services/UserService.cs
Normal file
@@ -0,0 +1,50 @@
|
||||
using DataAccessLayer;
|
||||
using DataAccessLayer.Entities;
|
||||
|
||||
namespace BusinessLayer.Services
|
||||
{
|
||||
public class UserService : IUserService
|
||||
{
|
||||
private readonly IUserAccountRepository _userAccountRepository;
|
||||
|
||||
public UserService(IUserAccountRepository userAccountRepository)
|
||||
{
|
||||
_userAccountRepository = userAccountRepository;
|
||||
}
|
||||
|
||||
public IEnumerable<UserAccount> GetAll(int? limit, int? offset)
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user