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)));
        }
示例#2
0
        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);
        }
示例#3
0
 public BorrowDto UpdateLoanForFriend(int?tapeId, int?friendId, BorrowInputModel borrow)
 {
     return(_tapeRepository.UpdateLoanForFriend(tapeId, friendId, borrow));
 }