// PUT: api/Borrowers/5 /// <summary> /// Edycja informacji wypożyczającego o podanym ID /// </summary> public async Task <IHttpActionResult> PutBorrower(int id, Borrower inputModel) { if (inputModel == null) { return(BadRequest(message: "empty model")); } if (id != inputModel.ID) { return(BadRequest()); } var borrower = await _borrowerRepository.GetByIdAsync(id); if (borrower == null) { return(NotFound()); } borrower.FirstName = inputModel.FirstName; borrower.LastName = inputModel.LastName; var result = await _borrowerRepository.SaveAsync(borrower); if (!result) { return(InternalServerError()); } return(Ok()); }
public async Task <ActionResult> Create(Borrower borrower) { if (ModelState.IsValid) { await _borrowerRepository.SaveAsync(borrower); return(RedirectToAction("Index")); } return(View(borrower)); }