Files
Backend-Api/CompanyManagment.EFCore/Repository/FinancialTransactionRepository.cs
2024-07-05 21:36:15 +03:30

52 lines
1.6 KiB
C#

using System.Linq;
using _0_Framework.Application;
using _0_Framework.InfraStructure;
using Company.Domain.FinancialTransactionAgg;
using CompanyManagment.App.Contracts.FinancilTransaction;
namespace CompanyManagment.EFCore.Repository;
public class FinancialTransactionRepository : RepositoryBase<long, FinancialTransaction>, IFinancialTransactionRepository
{
private readonly CompanyContext _context;
public FinancialTransactionRepository(CompanyContext context) : base(context)
{
_context = context;
}
public EditFinancialTransaction GetDetails(long id)
{
return _context.FinancialTransactions.Select(x => new EditFinancialTransaction()
{
Id = x.id,
TdateFa = x.TdateFa,
TdateGr = x.TdateGr,
Description = x.Description,
Deptor = x.Deptor,
DeptorString = x.Deptor.ToMoney(),
Creditor = x.Creditor,
CreditorString = x.Creditor.ToMoney(),
Balance = x.Balance,
MessageText = x.MessageText,
SentSms = x.SentSms,
SentSmsDateFa = x.SentSmsDateFa,
FinancialStatementId = x.FinancialStatementId,
TypeOfTransaction = x.TypeOfTransaction,
DescriptionOption = x.DescriptionOption.Trim(),
}).FirstOrDefault(x => x.Id == id);
}
public void RemoveFinancialTransaction(long id)
{
var res = _context.FinancialTransactions.FirstOrDefault(x => x.id == id);
if (res != null)
{
_context.FinancialTransactions.Remove(res);
_context.SaveChanges();
}
}
}