/// <summary> /// Save all sections & works to database (direct) /// </summary> /// <param name="id">id</param> /// <param name="companyId">companyId</param> public void Save(Guid id, int companyId) { FlatSectionJlinerTDS jlinerChanges = (FlatSectionJlinerTDS)Data.GetChanges(); if (jlinerChanges.JuntionLiner2Comment.Rows.Count > 0) { FlatSectionJlinerJuntionLiner2CommentGateway flatSectionJlinerJuntionLiner2CommentGateway = new FlatSectionJlinerJuntionLiner2CommentGateway(jlinerChanges); foreach (FlatSectionJlinerTDS.JuntionLiner2CommentRow row in (FlatSectionJlinerTDS.JuntionLiner2CommentDataTable)jlinerChanges.JuntionLiner2Comment) { // Insert new comments if ((!row.Deleted) && (!row.InDatabase)) { JlinerComments jlinerComments = new JlinerComments(null); jlinerComments.InsertDirect(row.ID, row.RefID, row.COMPANY_ID, row.CommentID, row.DateTime_, row.LoginID, row.Comment, row.Deleted); } // Update comments if ((!row.Deleted) && (row.InDatabase)) { int refId = row.RefID; int commentId = row.CommentID; // original values int originalLoginId = flatSectionJlinerJuntionLiner2CommentGateway.GetLoginIDOriginal(id, refId, companyId, commentId); DateTime? originalDateTime = null; if (flatSectionJlinerJuntionLiner2CommentGateway.GetDateTime_Original(id, refId, companyId, commentId) != null) originalDateTime = flatSectionJlinerJuntionLiner2CommentGateway.GetDateTime_Original(id, refId, companyId, commentId); string originalComment = flatSectionJlinerJuntionLiner2CommentGateway.GetCommentOriginal(id, refId, companyId, commentId); // new values string newComment = flatSectionJlinerJuntionLiner2CommentGateway.GetComment(id, refId, companyId, commentId); JlinerComments jlinerComments = new JlinerComments(null); jlinerComments.UpdateDirect(id, refId, companyId, commentId, originalDateTime, originalLoginId, originalComment, false, id, refId, companyId, commentId, originalDateTime, originalLoginId, newComment, false); } // Deleted lateral comments if ((row.Deleted)&& (row.InDatabase)) { JlinerComments jlinerComments = new JlinerComments(null); jlinerComments.DeleteDirect(row.ID, row.RefID, companyId, row.CommentID); } } } }