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, 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(); } } }