Repositories inserted and new page for accounts inserted

This commit is contained in:
2023-08-24 11:47:44 +02:00
parent 40632aa92c
commit 70c2d47e7b
16 changed files with 472 additions and 17 deletions

View 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;
}
}