/// <summary>
        /// Save support tickets
        /// </summary>
        /// <param name="creationDate">creationDate</param>        
        /// <param name="companyId">companyId</param>
        public int? Save(DateTime creationDate, int companyId)
        {
            int newSupportTicketId = 0;

            SupportTicketAddTDS supportTicketAddChanges = (SupportTicketAddTDS)Data.GetChanges();
            if (supportTicketAddChanges.BasicInformation.Rows.Count > 0)
            {
                foreach (SupportTicketAddTDS.BasicInformationRow row in (SupportTicketAddTDS.BasicInformationDataTable)supportTicketAddChanges.BasicInformation)
                {
                    int categoryId = row.CategoryID;
                    string subject = ""; if (!row.IsSubjectNull()) subject = row.Subject;
                    string comment = ""; if (!row.IsCommentNull()) comment = row.Comment;
                    DateTime? dueDate = null; if (!row.IsDueDateNull()) dueDate = row.DueDate;
                    int employeeId = 0; if (!row.IsTeamMemberIDNull()) employeeId = row.TeamMemberID;
                    bool deleted = row.Deleted;
                    string state = row.State;
                    int createdById = row.CreatedByID;
                    int refId = 1;
                    string type_ = row.Type_;

                    // ... Insert the support ticket
                    SupportTicketSupportTicket supportTicketSupportTicket = new SupportTicketSupportTicket(null);
                    newSupportTicketId = supportTicketSupportTicket.InsertDirect(categoryId, subject, creationDate, createdById, state, dueDate, deleted, companyId);

                    // ... Insert first Activity (Default Assignation - first Activity)
                    SupportTicketSupportTicketActivity supportTicketSupportTicketActivity = new SupportTicketSupportTicketActivity(null);
                    supportTicketSupportTicketActivity.InsertDirect(newSupportTicketId, refId, type_, creationDate, employeeId, comment, row.Deleted, companyId);
                }
            }

            return newSupportTicketId;
        }
        /// <summary>
        /// Save all activities to database (direct)
        /// </summary>
        /// <param name="companyId">companyId</param>
        public void Save(int companyId)
        {
            SupportTicketInformationTDS supportTicketInformationChanges = (SupportTicketInformationTDS)Data.GetChanges();

            if (supportTicketInformationChanges != null)
            {
                if (supportTicketInformationChanges.ActivityInformation.Rows.Count > 0)
                {
                    SupportTicketInformationActivityInformationGateway supportTicketInformationActivityInformationGateway = new SupportTicketInformationActivityInformationGateway(supportTicketInformationChanges);

                    foreach (SupportTicketInformationTDS.ActivityInformationRow row in (SupportTicketInformationTDS.ActivityInformationDataTable)supportTicketInformationChanges.ActivityInformation)
                    {
                        // Insert new activity
                        if ((!row.Deleted) && (!row.InDataBase))
                        {
                            // new values
                            int supportTicketId = row.SupportTicketID;
                            int refId = row.RefID;

                            int employeeId = supportTicketInformationActivityInformationGateway.GetEmployeeID(supportTicketId, refId);
                            string type_ = supportTicketInformationActivityInformationGateway.GetType_(supportTicketId, refId);
                            DateTime dateTime_ = supportTicketInformationActivityInformationGateway.GetDateTime_(supportTicketId, refId);
                            string comment = supportTicketInformationActivityInformationGateway.GetComment(supportTicketId, refId);

                            SupportTicketSupportTicketActivity supportTicketSupportTicketActivity = new SupportTicketSupportTicketActivity(null);
                            supportTicketSupportTicketActivity.InsertDirect(supportTicketId, refId, type_, dateTime_, employeeId, comment, row.Deleted, row.COMPANY_ID);
                        }

                        // Update activities
                        if ((!row.Deleted) && (row.InDataBase))
                        {
                            int supportTicketId = row.SupportTicketID;
                            int refId = row.RefID;
                            bool originalDeleted = false;
                            int originalCompanyId = companyId;

                            // original values
                            int originalEmployeeId = supportTicketInformationActivityInformationGateway.GetEmployeeID(supportTicketId, refId);
                            string originalType_ = supportTicketInformationActivityInformationGateway.GetType_(supportTicketId, refId);
                            DateTime originalDateTime_ = supportTicketInformationActivityInformationGateway.GetDateTime_(supportTicketId, refId);
                            string originalComment = supportTicketInformationActivityInformationGateway.GetComment(supportTicketId, refId);

                            // new values
                            int newEmployeeId = supportTicketInformationActivityInformationGateway.GetEmployeeIDOriginal(supportTicketId, refId);
                            string newComment = supportTicketInformationActivityInformationGateway.GetCommentOriginal(supportTicketId, refId);

                            SupportTicketSupportTicketActivity supportTicketSupportTicketActivity = new SupportTicketSupportTicketActivity(null);
                            supportTicketSupportTicketActivity.UpdateDirect(supportTicketId, refId, originalType_, originalDateTime_, originalEmployeeId, originalComment, originalDeleted, originalCompanyId, supportTicketId, refId, originalType_, originalDateTime_, newEmployeeId, newComment, originalDeleted, originalCompanyId);
                        }

                        // Deleted activity
                        if ((row.Deleted) && (row.InDataBase))
                        {
                            SupportTicketSupportTicketActivity supportTicketSupportTicketActivity = new SupportTicketSupportTicketActivity(null);
                            supportTicketSupportTicketActivity.DeleteDirect(row.SupportTicketID, row.RefID, row.COMPANY_ID);
                        }
                    }
                }
            }
        }