public static async Task Execute ( CreateLoanAgreementInfo model, ILoanAgreementAggregateRepository loanAgreementRepo, IFinancierAggregateRepository financierRepo, IUnitOfWork unitOfWork ) { if (await loanAgreementRepo.Exists(model.Id)) { throw new InvalidOperationException($"This loan agreement already exists!"); } string errMsg = $"Unable to create loan agreement info, a financier with id {model.FinancierId} could not be found!"; Financier financier = await financierRepo.GetByIdAsync(model.FinancierId) ?? throw new InvalidOperationException(errMsg); LoanAgreement loanAgreement = new LoanAgreement ( new EconomicEvent(model.Id, EventType.CashReceiptFromLoanAgreement), FinancierId.Create(financier.Id), LoanAmount.Create(model.LoanAmount), InterestRate.Create(model.InterestRate), LoanDate.Create(model.LoanDate), MaturityDate.Create(model.MaturityDate), PaymentsPerYear.Create(model.PaymentsPerYear), model.UserId ); await loanAgreementRepo.AddAsync(loanAgreement); await unitOfWork.Commit(); }
public LoanAgreementAggregateCommandHandler ( IFinancierAggregateRepository financierRepo, ILoanAgreementAggregateRepository loanAgreementRepo, IUnitOfWork unitOfWork ) { _financierRepo = financierRepo; _loanAgreementRepo = loanAgreementRepo; _unitOfWork = unitOfWork; }
public static Task Execute(IWriteModel model, IFinancierAggregateRepository repo, IUnitOfWork unitOfWork) => model switch {
public FinancierAggregateRepoTests() { TestDataInitialization.InitializeData(_dbContext); _unitOfWork = new AppUnitOfWork(_dbContext); _financierRepo = new FinancierAggregateRepository(_dbContext); }
public FinancierAggregateCommandHandler(IFinancierAggregateRepository repo, IUnitOfWork unitOfWork) { _financierRepo = repo; _unitOfWork = unitOfWork; }