public async Task <IActionResult> PutLoan(int id, ExpenseService.DataAccess.Model.Loan loan) { if (id != loan.Id) { return(BadRequest()); } var newLoan = Mapper.MapLoan(loan); _repo.Changed(newLoan); try { await _repo.SaveAsync(); } catch (DbUpdateConcurrencyException) { if (!(await LoanExists(id))) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <ActionResult> PostLoan(ExpenseService.DataAccess.Model.Loan loan) { var newLoan = Mapper.MapLoan(loan); _ = _repo.AddLoanAsync(newLoan); await _repo.SaveAsync(); return(CreatedAtAction("GetLoan", new { id = loan.Id }, loan)); }
public static Core.Model.CoreLoan MapLoan(Model.Loan loan) { return(new Core.Model.CoreLoan { Id = loan.Id, AccumulatedCost = loan.AccumulatedCost, RetainingCost = loan.RetainingCost, InterestRate = loan.InterestRate, MonthlyRate = loan.MonthlyRate, UserId = loan.UserId, //CurrentUser = MapUsers(loan.User) }); }