/// <summary> /// Save all comments to database (direct) /// </summary> /// <param name="companyId">companyId</param> public void Save(int companyId) { FlatSectionJlTDS flatSectionJlCommentDetailsChanges = (FlatSectionJlTDS)Data.GetChanges(); if (flatSectionJlCommentDetailsChanges.FlatSectionJlCommentDetails.Rows.Count > 0) { FlatSectionJlCommentDetailsGateway flatSectionJlCommentDetailsGateway = new FlatSectionJlCommentDetailsGateway(flatSectionJlCommentDetailsChanges); foreach (FlatSectionJlTDS.FlatSectionJlCommentDetailsRow row in (FlatSectionJlTDS.FlatSectionJlCommentDetailsDataTable)flatSectionJlCommentDetailsChanges.FlatSectionJlCommentDetails) { // Insert new comments if ((!row.Deleted) && (!row.InDatabase)) { WorkComments workComments = new WorkComments(null); int? libraryFilesId = null; if (!row.IsLIBRARY_FILES_IDNull()) libraryFilesId = row.LIBRARY_FILES_ID; string workType = ""; if (!row.IsWorkTypeNull()) workType = row.WorkType; workComments.InsertDirect(row.WorkID, row.RefID, row.Type, row.Subject, row.UserID, row.DateTime_, row.Comment, libraryFilesId, row.Deleted, row.COMPANY_ID, workType); } // Update comments if ((!row.Deleted) && (row.InDatabase)) { int workId = row.WorkID; int refId = row.RefID; bool originalDeleted = false; int originalCompanyId = companyId; // original values string originalType = flatSectionJlCommentDetailsGateway.GetTypeOriginal(workId, refId); string originalSubject = flatSectionJlCommentDetailsGateway.GetSubjectOriginal(workId, refId); int originalUserId = flatSectionJlCommentDetailsGateway.GetUserIdOriginal(workId, refId); DateTime? originalDateTime = null; if (flatSectionJlCommentDetailsGateway.GetDateTime_Original(workId, refId) != null) originalDateTime = flatSectionJlCommentDetailsGateway.GetDateTime_Original(workId, refId); string originalComment = flatSectionJlCommentDetailsGateway.GetCommentOriginal(workId, refId); int? originalLibraryFilesId = null; if (flatSectionJlCommentDetailsGateway.GetLIBRARY_FILES_IDOriginal(workId, refId) != null) originalLibraryFilesId = flatSectionJlCommentDetailsGateway.GetLIBRARY_FILES_IDOriginal(workId, refId); string originalWorkType = flatSectionJlCommentDetailsGateway.GetWorkTypeOriginal(workId, refId); // new values string newSubject = flatSectionJlCommentDetailsGateway.GetSubject(workId, refId); string newComment = flatSectionJlCommentDetailsGateway.GetComment(workId, refId); int? newLibraryFilesId = null; if (flatSectionJlCommentDetailsGateway.GetLIBRARY_FILES_IDOriginal(workId, refId) != null) originalLibraryFilesId = flatSectionJlCommentDetailsGateway.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, originalType, newSubject, originalUserId, originalDateTime, newComment, newLibraryFilesId, originalDeleted, originalCompanyId, originalWorkType); } // Deleted comments if ((row.Deleted) && (row.InDatabase)) { WorkComments workComments = new WorkComments(null); workComments.DeleteDirect(row.WorkID, row.RefID, row.COMPANY_ID); } } } }