public IActionResult GetBorrowHistory(int id)
        {
            if (id <= 0)
            {
                return(BadRequest());
            }

            var b = GetById(id);

            if (b == null)
            {
                return(NotFound());
            }

            var borrowHistory = new BorrowHistoryViewModel
            {
                Id         = b.Id,
                BookId     = b.BookId,
                CustomerId = b.CustomerId,
                BorrowDate = b.BorrowDate,
                ReturnDate = b.ReturnDate
            };

            return(Ok(borrowHistory));
        }
        public IActionResult Edit([FromBody] BorrowHistoryViewModel b)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest("Not a valid model"));
            }

            var existing = GetById(b.Id);

            if (existing != null)
            {
                existing.Id         = b.Id;
                existing.BookId     = b.BookId;
                existing.CustomerId = b.CustomerId;
                existing.BorrowDate = b.BorrowDate;
                existing.ReturnDate = b.ReturnDate;

                _context.SaveChanges();
            }
            else
            {
                return(NotFound());
            }

            return(Ok());
        }
        public IActionResult AddBorrowHistory(BorrowHistoryViewModel b)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest("Invalid data."));
            }

            var now = Utility.GetTurkeyCurrentDateTime();

            var borrowHistory = new BorrowHistoryModel
            {
                Id         = b.Id,
                BookId     = b.BookId,
                CustomerId = b.CustomerId,
                BorrowDate = now,
                ReturnDate = b.ReturnDate
            };

            _context.BorrowHistories.Add(borrowHistory);
            _context.SaveChanges();

            return(Ok(borrowHistory));
        }