public void ReturnBook(ReturnBookDTO dto) { using (var connection = _dbConnectionFactory.GetConnection()) { var sql = "UPDATE rent_history SET ReturnDate=@returnDate WHERE RentId=@rentId"; connection.Execute(sql, new { rentId = dto.RentId, returnDate = dto.ReturnDate }); } }
public void ChangeNote(ReturnBookDTO item) { var note = _libraryWorks.Where(x => x.BookId == item.BookId) .Where(x => x.ClientId == item.ClientId) .Where(x => x.ActualDateReturn == null).First(); note.ActualDateReturn = item.Date; _context.LibraryWorks.Update(note); _context.Save(); }
public async Task <ActionResult <IEnumerable <AddBook> > > Renew(ReturnBookDTO request) { foreach (var item in request.Id) { var library_item = await _context.Library.SingleOrDefaultAsync(x => x.Id == item); library_item.Renewed = library_item.Renewed + 1; await _context.SaveChangesAsync(); } return(CreatedAtAction("GetLibraryBooks", request)); }
public async Task <ActionResult <IEnumerable <LoanBookDTO> > > ReturnBook(ReturnBookDTO request) { foreach (var item in request.Id) { var library_item = await _context.Library.SingleOrDefaultAsync(x => x.Id == item); library_item.Return_date = DateTime.UtcNow; await _context.SaveChangesAsync(); } return(CreatedAtAction("GetLibraryBooks", request)); }
public void ReturnBook(ReturnBookDTO dto) { var sql = "UPDATE rent_history SET ReturnDate=@returnDate WHERE RentId=@rentId"; _dbHelper.ExecuteNonQuery(sql, new List <MySqlParameter> { new MySqlParameter { ParameterName = "@rentId", MySqlDbType = MySqlDbType.Guid, Value = dto.RentId }, new MySqlParameter { ParameterName = "@dateIssued", MySqlDbType = MySqlDbType.Date, Value = dto.ReturnDate } }.ToArray()); }
public async Task <IActionResult> ReturnBook([FromBody] ReturnBookDTO form) { try { await libraryRecordFacade.ReturnBookAsync(form); Response.StatusCode = (int)HttpStatusCode.OK; return(Json(new { responseText = "Your form successfuly sent!" })); } catch (Exception ex) { Response.StatusCode = (int)HttpStatusCode.BadRequest; return(Json(new { responseText = ex.Message })); } }
public IEnumerable <ReturnBookDTO> GetBorrowedBooks() { List <ReturnBookDTO> returnBookDTOs = new List <ReturnBookDTO>(); var bookCopies = _BookCopyService.GetBorrowedBooks(); foreach (var bookCopy in bookCopies) { var bookInfo = _BookInfoService.BookInfoOf(bookCopy); var lastTrans = _BookTransactionInfoRepository.GetLastBookTransaction(bookCopy.Id); //If no borrow transaction was found, then its a possible error. if (lastTrans != null) { var requiredFee = ComputeNecessaryFee(bookCopy, lastTrans); var user = _LibraryUserService.FindById(lastTrans.LibraryUserId); var newReturnBookDTO = new ReturnBookDTO(); newReturnBookDTO.LibraryUser = user; newReturnBookDTO.BookInfo = bookInfo; newReturnBookDTO.RequiredFee = requiredFee; newReturnBookDTO.BookCopy = bookCopy; if (user.LibraryUserType == LibraryUser.UserType.Student) { newReturnBookDTO.TransactionInfo = new JustReturnBookTransaction(bookCopy, lastTrans); } else if (user.LibraryUserType == LibraryUser.UserType.Instructor || user.LibraryUserType == LibraryUser.UserType.Employee) { newReturnBookDTO.TransactionInfo = new ReturnBookIgnorePaymentTransaction(bookCopy, lastTrans); } returnBookDTOs.Add(newReturnBookDTO); } else { Debug.WriteLine("Possible error. A book was borrowed but no transaction info was found."); } } return(returnBookDTOs); }
public async Task ReturnBookAsync(ReturnBookDTO returnBookDTO) { await libraryRecordRepository.ModifyAsync(record => { record.ReturnBook(new BookId(returnBookDTO.bookId), new BookAmount(Convert.ToInt32(returnBookDTO.bookAmount))); }, new LibraryRecordId(returnBookDTO.libraryRecordId)); }