| | 1 | | using System; |
| | 2 | | using System.Collections.Generic; |
| | 3 | | using System.Text; |
| | 4 | | using MUNity.Extensions.ResolutionExtensions; |
| | 5 | |
|
| | 6 | | namespace MUNity.Models.Resolution |
| | 7 | | { |
| | 8 | | /// <summary> |
| | 9 | | /// An Amendment to move an operative paragraph to a new position. |
| | 10 | | /// </summary> |
| | 11 | | public class MoveAmendment : AbstractAmendment |
| | 12 | | { |
| | 13 | | /// <summary> |
| | 14 | | /// The Id of the virtual paragraph that represents the new position of the operative paragraph. |
| | 15 | | /// </summary> |
| 0 | 16 | | public string NewTargetSectionId { get; set; } |
| | 17 | |
|
| | 18 | | /// <summary> |
| | 19 | | /// Will delete the opld amendment and move all its settings to the currently virtual paragraph. |
| | 20 | | /// </summary> |
| | 21 | | /// <param name="parentSection"></param> |
| | 22 | | /// <returns></returns> |
| | 23 | | public override bool Apply(OperativeSection parentSection) |
| 0 | 24 | | { |
| 0 | 25 | | var placeholder = parentSection.FindOperativeParagraph(NewTargetSectionId); |
| 0 | 26 | | var target = parentSection.FindOperativeParagraph(TargetSectionId); |
| | 27 | |
|
| 0 | 28 | | if (target == null || placeholder == null) |
| 0 | 29 | | return false; |
| | 30 | |
|
| 0 | 31 | | placeholder.Children = target.Children; |
| 0 | 32 | | placeholder.Corrected = target.Corrected; |
| 0 | 33 | | placeholder.IsLocked = false; |
| 0 | 34 | | placeholder.IsVirtual = false; |
| 0 | 35 | | placeholder.Name = target.Name; |
| 0 | 36 | | placeholder.OperativeParagraphId = target.OperativeParagraphId; |
| 0 | 37 | | target.OperativeParagraphId = Guid.NewGuid().ToString(); |
| 0 | 38 | | this.TargetSectionId = target.OperativeParagraphId; |
| 0 | 39 | | placeholder.Text = target.Text; |
| 0 | 40 | | placeholder.Visible = true; |
| 0 | 41 | | parentSection.RemoveOperativeParagraph(target); |
| 0 | 42 | | return true; |
| 0 | 43 | | } |
| | 44 | |
|
| | 45 | | /// <summary> |
| | 46 | | /// Will remove the amendment and the virtual paragraph. |
| | 47 | | /// </summary> |
| | 48 | | /// <param name="parentSection"></param> |
| | 49 | | /// <returns></returns> |
| | 50 | | public override bool Deny(OperativeSection parentSection) |
| 0 | 51 | | { |
| 0 | 52 | | parentSection.RemoveAmendment(this); |
| 0 | 53 | | return true; |
| 0 | 54 | | } |
| | 55 | | } |
| | 56 | | } |