public IActionResult Edit(int id, LoanForEmploy loanForEmploy) { //Test if Id on method is different than loan id if (id != loanForEmploy.ID) { return(BadRequest()); } //If is all Ok _loanForEmployService.Update(loanForEmploy); //Return to index return(RedirectToAction(nameof(Index))); }
//Update Loans public void Update(LoanForEmploy obj) { //Test if id exists if (!_context.LOAN_FOR_EMPLOY.Any(x => x.ID == obj.ID)) { throw new NotFoundException("Id not Found"); } //Update Loan _context.Update(obj); //Save changes _context.SaveChanges(); }