66 lines
2.5 KiB
C#
66 lines
2.5 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using _0_Framework.Application;
|
|
using _0_Framework.InfraStructure;
|
|
using Company.Domain.FinancialStatmentAgg;
|
|
using CompanyManagment.App.Contracts.FinancialStatment;
|
|
using CompanyManagment.App.Contracts.FinancilTransaction;
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
namespace CompanyManagment.EFCore.Repository;
|
|
|
|
public class FinancialStatmentRepository : RepositoryBase<long, FinancialStatment>, IFinancialStatmentRepository
|
|
|
|
{
|
|
private readonly CompanyContext _context;
|
|
|
|
public FinancialStatmentRepository(CompanyContext context) : base(context)
|
|
{
|
|
_context = context;
|
|
}
|
|
|
|
|
|
public FinancialStatmentViewModel GetDetailsByContractingPartyId(long contractingPartyId)
|
|
{
|
|
var res = _context.FinancialStatments.Include(x => x.FinancialTransactionList)
|
|
.FirstOrDefault(x => x.ContractingPartyId == contractingPartyId);
|
|
if (res == null)
|
|
{
|
|
return new FinancialStatmentViewModel();
|
|
}
|
|
else
|
|
{
|
|
|
|
return new FinancialStatmentViewModel()
|
|
{
|
|
Id = res.id,
|
|
ContractingPartyId = res.ContractingPartyId,
|
|
ContractingPartyName = res.ContractingPartyName,
|
|
FinancialTransactionViewModels = res.FinancialTransactionList.Select(t => new FinancialTransactionViewModel()
|
|
{
|
|
Id = t.id,
|
|
TdateFa = t.TdateFa,
|
|
TdateGr = t.TdateGr,
|
|
Description = t.TypeOfTransaction == "debt" ? "ایجاد درآمد" + " " + t.DescriptionOption + " " + t.Description : "دریافت درآمد" + " " + t.DescriptionOption + " " + t.Description,
|
|
Deptor = t.Deptor,
|
|
DeptorString = t.Deptor!=0?t.Deptor.ToMoney():"",
|
|
Creditor = t.Creditor,
|
|
CreditorString = t.Creditor!=0?t.Creditor.ToMoney():"",
|
|
Balance = t.Balance,
|
|
MessageText = t.MessageText,
|
|
SentSms = t.SentSms,
|
|
SentSmsDateFa = t.SentSmsDateFa,
|
|
FinancialStatementId = t.FinancialStatementId,
|
|
TypeOfTransaction = t.TypeOfTransaction
|
|
}).OrderBy(t=>t.TdateGr).ToList(),
|
|
};
|
|
}
|
|
|
|
}
|
|
|
|
public List<FinancialStatmentViewModel> Search(FinancialStatmentSearchModel searchModel)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
} |