public IActionResult UpdateLoanForFriend([FromBody] BorrowInputModel borrow, int?tapeId, int?friendId) { if (!ModelState.IsValid) { throw new ModelFormatException(); } return(Ok(_tapeService.UpdateLoanForFriend((int)tapeId, (int)friendId, borrow))); }
public BorrowDto UpdateLoanForFriend(int?tapeId, int?friendId, BorrowInputModel borrow) { CheckIfUserOrTapeExist(tapeId, friendId); var borrowEntity = (from b in _dataBaseContext.Borrows where friendId == b.FriendId && tapeId == b.TapeId select b).FirstOrDefault(); if (borrowEntity == null) { throw new ResourceNotFoundException(); } // update the borrow information borrowEntity.BorrowDate = borrow.BorrowDate; borrowEntity.FriendId = borrow.FriendId; borrowEntity.ReturnDate = borrow.ReturnDate; _dataBaseContext.SaveChanges(); // return update borrow dto var borrowDto = Mapper.Map <BorrowDto>(borrowEntity); return(borrowDto); }
public BorrowDto UpdateLoanForFriend(int?tapeId, int?friendId, BorrowInputModel borrow) { return(_tapeRepository.UpdateLoanForFriend(tapeId, friendId, borrow)); }