/// <summary>
        /// Save all comments to database (direct)
        /// </summary>
        /// <param name="originalWorkId">originalWorkId</param>
        /// <param name="companyId">companyId</param>        
        public void Save(int originalWorkId, int companyId)
        {
            RehabAssessmentTDS rehabAssessmentCommentDetailsChanges = (RehabAssessmentTDS)Data.GetChanges();

            if (rehabAssessmentCommentDetailsChanges.CommentDetails.Rows.Count > 0)
            {
                RehabAssessmentCommentDetailsGateway rehabAssessmentCommentDetailsGateway = new RehabAssessmentCommentDetailsGateway(rehabAssessmentCommentDetailsChanges);

                foreach (RehabAssessmentTDS.CommentDetailsRow row in (RehabAssessmentTDS.CommentDetailsDataTable)rehabAssessmentCommentDetailsChanges.CommentDetails)
                {
                    // Insert new comment
                    if ((!row.Deleted) && (!row.InDatabase))
                    {
                        WorkComments workComments = new WorkComments(null);
                        int? libraryFilesId = null; if (!row.IsLIBRARY_FILES_IDNull()) libraryFilesId = row.LIBRARY_FILES_ID;

                        workComments.InsertDirect(row.WorkID, row.RefID, row.Type, row.Subject, row.UserID, row.DateTime_, row.Comment, libraryFilesId, row.Deleted, row.COMPANY_ID, row.WorkType);
                    }

                    // Update comment
                    if ((!row.Deleted) && (row.InDatabase))
                    {
                        int workId = row.WorkID;
                        int refId = row.RefID;
                        bool originalDeleted = false;
                        int originalCompanyId = companyId;

                        // original values
                        string originalType = rehabAssessmentCommentDetailsGateway.GetTypeOriginal(workId, refId);
                        string originalSubject = rehabAssessmentCommentDetailsGateway.GetSubjectOriginal(workId, refId);
                        int originalUserId = rehabAssessmentCommentDetailsGateway.GetUserIdOriginal(workId, refId);
                        DateTime? originalDateTime = null; if (rehabAssessmentCommentDetailsGateway.GetDateTime_Original(workId, refId) != null) originalDateTime = rehabAssessmentCommentDetailsGateway.GetDateTime_Original(workId, refId);
                        string originalComment = rehabAssessmentCommentDetailsGateway.GetCommentOriginal(workId, refId);
                        int? originalLibraryFilesId = null; if (rehabAssessmentCommentDetailsGateway.GetLIBRARY_FILES_IDOriginal(workId, refId) != null) originalLibraryFilesId = rehabAssessmentCommentDetailsGateway.GetLIBRARY_FILES_IDOriginal(workId, refId);
                        string originalWorkType = rehabAssessmentCommentDetailsGateway.GetWorkTypeOriginal(workId, refId);

                        // new values
                        string newType = rehabAssessmentCommentDetailsGateway.GetType(workId, refId);
                        string newSubject = rehabAssessmentCommentDetailsGateway.GetSubject(workId, refId);
                        string newComment = rehabAssessmentCommentDetailsGateway.GetComment(workId, refId);
                        int? newLibraryFilesId = null; if (rehabAssessmentCommentDetailsGateway.GetLIBRARY_FILES_IDOriginal(workId, refId) != null) originalLibraryFilesId = rehabAssessmentCommentDetailsGateway.GetLIBRARY_FILES_ID(workId, refId);

                        WorkComments workComments = new WorkComments(null);
                        workComments.UpdateDirect(workId, refId, originalType, originalSubject, originalUserId, originalDateTime, originalComment, originalLibraryFilesId, originalDeleted, originalCompanyId, originalWorkType, workId, refId, newType, newSubject, originalUserId, originalDateTime, newComment, newLibraryFilesId, originalDeleted, originalCompanyId, originalWorkType);
                    }

                    // Deleted comment
                    if ((row.Deleted) && (row.InDatabase))
                    {
                        WorkComments workComments = new WorkComments(null);
                        workComments.DeleteDirect(row.WorkID, row.RefID, row.COMPANY_ID);
                    }

                }
            }
        }