public bool AcceptRequest(string reqID) { BUS.RequestBUS reqBUS = new BUS.RequestBUS(); //reqBUS.UpdateRequest(reqID, 2); DAO.RequestDAO reqDAO = new DAO.RequestDAO(); DTO.RequestDTO reqDTO = reqDAO.SearchRequestByRequestID(reqID); DAO._MultiTableDAO mulDAO = new DAO._MultiTableDAO(); DataTable dt = mulDAO.FindBookIDAndInventoryIDByBookTitleID(reqDTO.BookTitleID, "0").Tables[0]; if (dt != null) { string bookID, inventoryID; try { bookID = dt.Rows[0]["BookID"].ToString(); inventoryID = dt.Rows[0]["InventoryID"].ToString(); } catch (Exception ex) { return(false); } Console.WriteLine(bookID); Console.WriteLine(inventoryID); if (bookID != null && inventoryID != null) { try { bool result = true; result &= reqBUS.UpdateRequest(reqID, 2); Console.WriteLine(result); InventoryBUS invBUS = new InventoryBUS(); result &= invBUS.UpdateInventory(inventoryID, 1); Console.WriteLine(result); LoanBUS loBUS = new LoanBUS(); if (result) { result &= loBUS.AddNewLoan(reqID, bookID); Console.WriteLine(result); if (result == true) { stt = "Inventory: " + inventoryID; } return(result); } else { reqBUS.UpdateRequest(reqID, 0); invBUS.UpdateInventory(inventoryID, 0); } } catch (Exception ex) { Console.WriteLine("Exception: " + ex.Message); reqBUS.UpdateRequest(reqID, 0); InventoryBUS invBUS = new InventoryBUS(); invBUS.UpdateInventory(inventoryID, 0); } } } return(false); }
private DTO.RequestDTO SearchRequestByRequestID(string id) { return(dao.SearchRequestByRequestID(id)); }