| | 1 | | using System; |
| | 2 | | using System.Collections.Generic; |
| | 3 | | using System.Text; |
| | 4 | | using MUNity.Extensions.ResolutionExtensions; |
| | 5 | | using MUNity.Extensions.ObservableCollectionExtensions; |
| | 6 | |
|
| | 7 | | namespace MUNity.Models.Resolution |
| | 8 | | { |
| | 9 | |
|
| | 10 | | /// <summary> |
| | 11 | | /// The Delete Amendment is a type of amendment to remove an operative paragraph from the resolution. |
| | 12 | | /// </summary> |
| | 13 | | public class DeleteAmendment : AbstractAmendment |
| | 14 | | { |
| | 15 | | /// <summary> |
| | 16 | | /// Removes the operative section with all children and amendments that are on it. |
| | 17 | | /// </summary> |
| | 18 | | /// <param name="parentSection"></param> |
| | 19 | | /// <returns></returns> |
| | 20 | | public override bool Apply(OperativeSection parentSection) |
| 0 | 21 | | { |
| 0 | 22 | | var paragraph = parentSection.FindOperativeParagraph(this.TargetSectionId); |
| | 23 | |
|
| 0 | 24 | | if (!parentSection.Paragraphs.Contains(paragraph)) |
| 0 | 25 | | return false; |
| | 26 | |
|
| 0 | 27 | | parentSection.Paragraphs.Remove(paragraph); |
| | 28 | |
|
| 0 | 29 | | parentSection.AmendmentsForOperativeParagraph(this.TargetSectionId).ForEach(n => parentSection.RemoveAmendme |
| 0 | 30 | | return true; |
| 0 | 31 | | } |
| | 32 | |
|
| | 33 | | /// <summary> |
| | 34 | | /// Removes the delete amendment and all other delete amendments that are targeting the same operative paragraph |
| | 35 | | /// </summary> |
| | 36 | | /// <param name="section"></param> |
| | 37 | | /// <returns></returns> |
| | 38 | | public override bool Deny(OperativeSection section) |
| 0 | 39 | | { |
| 0 | 40 | | var count = section.DeleteAmendments.RemoveAll(n => |
| 0 | 41 | | n.TargetSectionId == this.TargetSectionId); |
| | 42 | |
|
| 0 | 43 | | return count > 0; |
| 0 | 44 | | } |
| | 45 | | } |
| | 46 | | } |