Repositories inserted and new page for accounts inserted
This commit is contained in:
58
WinFormDi.BLR/AccountRecordRepository.cs
Normal file
58
WinFormDi.BLR/AccountRecordRepository.cs
Normal file
@ -0,0 +1,58 @@
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using WinFormDiApp.BL.Models;
|
||||
using WinFormDiApp.BLI;
|
||||
using WinFormDiApp.DAL;
|
||||
|
||||
namespace WinFormDiApp.BLR;
|
||||
|
||||
public class AccountRecordRepository : IAccountRecordRepository
|
||||
{
|
||||
private readonly ApplicationDbContext _dataContext;
|
||||
private readonly IConfiguration _configuration;
|
||||
private readonly ILogger<AccountRecordRepository> _logger;
|
||||
|
||||
public AccountRecordRepository(ApplicationDbContext dataContext, IConfiguration configuration, ILogger<AccountRecordRepository> logger)
|
||||
{
|
||||
_dataContext = dataContext;
|
||||
_configuration = configuration;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public bool AddAccountRecord(AccountRecord record)
|
||||
{
|
||||
try
|
||||
{
|
||||
_dataContext.AccountRecords.Add(record);
|
||||
_dataContext.SaveChanges();
|
||||
return true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_logger.LogError($"Error occured in AddAccountRecord :{e.Message}");
|
||||
}
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
public bool DeleteAccountRecord(AccountRecord record)
|
||||
{
|
||||
try
|
||||
{
|
||||
_dataContext.AccountRecords.Remove(record);
|
||||
_dataContext.SaveChanges();
|
||||
return true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_logger.LogError($"Error occured in DeleteAccountRecord :{e.Message}");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public IEnumerable<AccountRecord> GetAllAccounts()
|
||||
{
|
||||
return _dataContext.AccountRecords;
|
||||
}
|
||||
|
||||
}
|
||||
29
WinFormDi.BLR/MemberRepository.cs
Normal file
29
WinFormDi.BLR/MemberRepository.cs
Normal file
@ -0,0 +1,29 @@
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using WinFormDiApp.BL.Models;
|
||||
using WinFormDiApp.BLI;
|
||||
using WinFormDiApp.DAL;
|
||||
|
||||
namespace WinFormDiApp.BLR;
|
||||
|
||||
public class MemberRepository : IMemberRepository
|
||||
{
|
||||
private readonly ApplicationDbContext _dataContext;
|
||||
private readonly IConfiguration _configuration;
|
||||
private readonly ILogger<MemberRepository> _logger;
|
||||
|
||||
public MemberRepository(ApplicationDbContext dataContext, IConfiguration configuration, ILogger<MemberRepository> logger)
|
||||
{
|
||||
_dataContext = dataContext;
|
||||
_configuration = configuration;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public IEnumerable<Member> InsertMember(Member member)
|
||||
{
|
||||
_dataContext.Members.Add(member);
|
||||
_dataContext.SaveChanges();
|
||||
return _dataContext.Members.ToArray();
|
||||
}
|
||||
|
||||
}
|
||||
15
WinFormDi.BLR/WinFormDiApp.BLR.csproj
Normal file
15
WinFormDi.BLR/WinFormDiApp.BLR.csproj
Normal file
@ -0,0 +1,15 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\WinFormDi.BLI\WinFormDiApp.BLI.csproj" />
|
||||
<ProjectReference Include="..\WinFormDiApp.BL\WinFormDiApp.BL.csproj" />
|
||||
<ProjectReference Include="..\WinFormDiApp.DAL\WinFormDiApp.DAL.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
Reference in New Issue
Block a user