public async Task <IActionResult> Edit(int id, [Bind("IsPaid,LoanId,ReceiptRowId,Involvement,Id")] LoanRow loanRow) { if (id != loanRow.Id) { return(NotFound()); } if (ModelState.IsValid) { _uow.LoanRows.Update(loanRow); await _uow.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } var viewModel = new LoanRowViewModel { LoanRow = loanRow, Loans = new SelectList(await _uow.Loans.AllAsync(), nameof(Loan.Id), nameof(Loan.Id)), ReceiptRows = new SelectList(await _uow.ReceiptRows.AllAsync(), nameof(ReceiptRow.Id), nameof(ReceiptRow.Id)) }; return(View(viewModel)); }
/// <summary> /// Maps Id, ReceiptRowId, LoanDTO -> ParticipantDTO -> ReceiptDTO /// </summary> /// <param name="loanRow"></param> /// <returns></returns> /// <exception cref="NullReferenceException"></exception> public static DALLoanRowDTO FromDomain(LoanRow loanRow) { if (loanRow == null) { throw new NullReferenceException("Can't map, loanRow entity is null"); } return(new DALLoanRowDTO() { Id = loanRow.Id, ReceiptRowId = loanRow.ReceiptRowId, Loan = LoanMapper.FromDomain(loanRow.Loan) }); }