/// <summary> /// Creates a Move Amendment. This will also create a new Operative paragraph at the palce where the amendment should be moved to. Not that this virtual Paragraph /// will copy the text once when the amendment is created and once when the amendment is accepted. If the text of the paragraph changed in the mean time the displayed /// text of the virtual operative paragraph may differ. /// </summary> /// <param name="section"></param> /// <param name="paragraphId"></param> /// <param name="targetIndex"></param> /// <param name="parentParagraph"></param> /// <returns></returns> public static MoveAmendment CreateMoveAmendment(this OperativeSection section, string paragraphId, int targetIndex, OperativeParagraph parentParagraph = null) { var sourceParagraph = section.FindOperativeParagraph(paragraphId); if (sourceParagraph == null) { throw new MUNity.Exceptions.Resolution.OperativeParagraphNotFoundException(); } var newAmendment = new MoveAmendment { TargetSectionId = paragraphId }; var virtualParagraph = new OperativeParagraph { IsLocked = true, IsVirtual = true, Text = sourceParagraph.Text }; newAmendment.NewTargetSectionId = virtualParagraph.OperativeParagraphId; section.InsertIntoRealPosition(virtualParagraph, targetIndex, parentParagraph); section.PushAmendment(newAmendment); return(newAmendment); }
public static MoveAmendment ToModel(this ResaMoveAmendment sourceAmendment) { var model = new MoveAmendment() { Activated = sourceAmendment.Activated, Id = sourceAmendment.ResaAmendmentId, Name = sourceAmendment.GetType().Name, NewTargetSectionId = sourceAmendment.VirtualParagraph?.ResaOperativeParagraphId ?? "", SubmitterName = sourceAmendment.SubmitterName, SubmitTime = sourceAmendment.SubmitTime, TargetSectionId = sourceAmendment.SourceParagraph?.ResaOperativeParagraphId ?? "", Type = sourceAmendment.ResaAmendmentType }; return(model); }