public int?CreateTicket(Session session, TicketFactory ticketFactory) { int?ticketId = InsertReturnId(CreateTicketQuery, Config.Get("mysql_db"), ticketFactory.BuildInsertString(), ticketFactory.BuildValuesString()); if (ticketId != null) { foreach (var fieldId in ticketFactory.customFields.Keys) { InsertCustomField((int)ticketId, -1, fieldId, ticketFactory.customFields[fieldId]); } LogEvent(session, (int)ticketId, TICKET_EVENT.CREATED, ""); } return(ticketId); }