public string Save(Borrow borrow) { if (borrow.MemberId.ToString()== string.Empty) { return "Memeber Id is missing"; } else if (borrowGateway.HasThisMemberTakenBook(borrow.MemberId,borrow.BookId)) { return "This Memeber has already taken book."; } else { int value = borrowGateway.Save(borrow); if (value > 0) { return "Borrow Information Saved Successfully"; } else { return "Operation Failed"; } } }
public int Save(Borrow borrow) { SqlConnection connection = new SqlConnection(connectionstring); string query = "INSERT INTO Borrow_Return VALUES('"+borrow.MemberId+"','"+borrow.BookId+"')"; SqlCommand command = new SqlCommand(query, connection); connection.Open(); int rowsAffected = command.ExecuteNonQuery(); connection.Close(); return rowsAffected; }