| | 1 | | using MUNity.Extensions.Conversion; |
| | 2 | | using MUNity.Models.Resolution; |
| | 3 | | using System; |
| | 4 | | using System.Collections.Generic; |
| | 5 | | using System.Linq; |
| | 6 | | using System.Text; |
| | 7 | |
|
| | 8 | | namespace MUNity.Extensions.ResolutionExtensions |
| | 9 | | { |
| | 10 | |
|
| | 11 | | /// <summary> |
| | 12 | | /// This set of extension methods contains logic to work with operative paragraphs and the operative section. |
| | 13 | | /// </summary> |
| | 14 | | public static class OperativeParagraphTools |
| | 15 | | { |
| | 16 | |
|
| | 17 | | /// <summary> |
| | 18 | | /// Creates a new Operative paragraph inside a given OperativeSection. |
| | 19 | | /// </summary> |
| | 20 | | /// <param name="section"></param> |
| | 21 | | /// <param name="text"></param> |
| | 22 | | /// <returns></returns> |
| | 23 | | public static OperativeParagraph CreateOperativeParagraph(this OperativeSection section, string text = "") |
| 0 | 24 | | { |
| 0 | 25 | | var paragraph = new OperativeParagraph |
| 0 | 26 | | { |
| 0 | 27 | | Text = text |
| 0 | 28 | | }; |
| 0 | 29 | | section.Paragraphs.Add(paragraph); |
| 0 | 30 | | return paragraph; |
| 0 | 31 | | } |
| | 32 | |
|
| | 33 | | /// <summary> |
| | 34 | | /// Creates a new Child paragraph in a given Resolution. |
| | 35 | | /// </summary> |
| | 36 | | /// <param name="section"></param> |
| | 37 | | /// <param name="parentId"></param> |
| | 38 | | /// <param name="text"></param> |
| | 39 | | /// <returns></returns> |
| | 40 | | public static OperativeParagraph CreateChildParagraph(this OperativeSection section, string parentId, string tex |
| 0 | 41 | | { |
| 0 | 42 | | var parentParagraph = section.FindOperativeParagraph(parentId); |
| 0 | 43 | | if (parentParagraph == null) |
| 0 | 44 | | throw new MUNity.Exceptions.Resolution.OperativeParagraphNotFoundException(); |
| | 45 | |
|
| 0 | 46 | | var newParagraph = new OperativeParagraph |
| 0 | 47 | | { |
| 0 | 48 | | Text = text |
| 0 | 49 | | }; |
| 0 | 50 | | parentParagraph.Children.Add(newParagraph); |
| 0 | 51 | | return newParagraph; |
| 0 | 52 | | } |
| | 53 | |
|
| | 54 | | /// <summary> |
| | 55 | | /// Will also create a Child paragraph by calling the CreateChildParagraph function and pass the Id to it. |
| | 56 | | /// </summary> |
| | 57 | | /// <param name="section"></param> |
| | 58 | | /// <param name="parent"></param> |
| | 59 | | /// <param name="text"></param> |
| | 60 | | /// <returns></returns> |
| | 61 | | public static OperativeParagraph CreateChildParagraph(this OperativeSection section, OperativeParagraph parent, |
| 0 | 62 | | => section.CreateChildParagraph(parent.OperativeParagraphId, text); |
| | 63 | |
|
| | 64 | | /// <summary> |
| | 65 | | /// Will search for an Operative Paragraph with the given id. Will return null if the paragraph was not found. |
| | 66 | | /// </summary> |
| | 67 | | /// <param name="section"></param> |
| | 68 | | /// <param name="id"></param> |
| | 69 | | /// <returns></returns> |
| | 70 | | public static OperativeParagraph FindOperativeParagraph(this OperativeSection section, string id) |
| 0 | 71 | | { |
| 0 | 72 | | return section.FirstOrDefault(n => n.OperativeParagraphId == id); |
| 0 | 73 | | } |
| | 74 | |
|
| | 75 | | /// <summary> |
| | 76 | | /// An internal function to go throw all operative paragraphs and their child paragraphs and get the path of the |
| | 77 | | /// </summary> |
| | 78 | | /// <param name="paragraph"></param> |
| | 79 | | /// <param name="targetId"></param> |
| | 80 | | /// <param name="path"></param> |
| | 81 | | /// <returns></returns> |
| | 82 | | private static OperativeParagraph FindOperativeParagraphPathRecursive(OperativeParagraph paragraph, string targe |
| 0 | 83 | | { |
| 0 | 84 | | if (paragraph.OperativeParagraphId == targetId) |
| 0 | 85 | | { |
| 0 | 86 | | path.Add(paragraph); |
| 0 | 87 | | return paragraph; |
| | 88 | | } |
| 0 | 89 | | if (paragraph.Children != null && paragraph.Children.Any()) |
| 0 | 90 | | { |
| 0 | 91 | | foreach (var child in paragraph.Children) |
| 0 | 92 | | { |
| 0 | 93 | | var result = FindOperativeParagraphPathRecursive(child, targetId, path); |
| 0 | 94 | | if (result != null) |
| 0 | 95 | | { |
| 0 | 96 | | path.Add(paragraph); |
| 0 | 97 | | return result; |
| | 98 | | } |
| | 99 | |
|
| 0 | 100 | | } |
| 0 | 101 | | } |
| 0 | 102 | | return null; |
| 0 | 103 | | } |
| | 104 | |
|
| | 105 | | /// <summary> |
| | 106 | | /// Returns the Path of a Operative Paragraph as a List where every paragraph is an element to get to the last. |
| | 107 | | /// For Example |
| | 108 | | /// HeadParagraph > ChildParagraph1 > TargetParagraph. |
| | 109 | | /// </summary> |
| | 110 | | /// <param name="section"></param> |
| | 111 | | /// <param name="id"></param> |
| | 112 | | /// <returns></returns> |
| | 113 | | public static List<OperativeParagraph> GetOperativeParagraphPath(this OperativeSection section, string id) |
| 0 | 114 | | { |
| 0 | 115 | | var path = new List<OperativeParagraph>(); |
| 0 | 116 | | foreach (var paragraph in section.Paragraphs) |
| 0 | 117 | | { |
| 0 | 118 | | var result = FindOperativeParagraphPathRecursive(paragraph, id, path); |
| 0 | 119 | | if (result != null) |
| 0 | 120 | | { |
| 0 | 121 | | path.Reverse(); |
| 0 | 122 | | return path; |
| | 123 | | } |
| 0 | 124 | | } |
| 0 | 125 | | return null; |
| 0 | 126 | | } |
| | 127 | |
|
| | 128 | | /// <summary> |
| | 129 | | /// Removes an Operative Paragraph from the Operative Section. Will also remove all the amendments that |
| | 130 | | /// are targeting this paragraph. |
| | 131 | | /// </summary> |
| | 132 | | /// <param name="section"></param> |
| | 133 | | /// <param name="paragraph"></param> |
| | 134 | | public static void RemoveOperativeParagraph(this OperativeSection section, OperativeParagraph paragraph) |
| 0 | 135 | | { |
| 0 | 136 | | var path = section.GetOperativeParagraphPath(paragraph.OperativeParagraphId); |
| 0 | 137 | | if (path == null || !path.Any()) |
| 0 | 138 | | throw new MUNity.Exceptions.Resolution.OperativeParagraphNotFoundException(); |
| | 139 | |
|
| 0 | 140 | | if (path.Count == 1) |
| 0 | 141 | | { |
| 0 | 142 | | section.Paragraphs.Remove(paragraph); |
| 0 | 143 | | } |
| | 144 | | else |
| 0 | 145 | | { |
| 0 | 146 | | path[path.Count - 1].Children.Remove(paragraph); |
| 0 | 147 | | } |
| | 148 | |
|
| | 149 | | // TODO: Remove all Amendments of this paragraph and all its child paragraphs! |
| 0 | 150 | | foreach (var amendment in section.AddAmendments.Where(n => n.TargetSectionId == paragraph.OperativeParagraph |
| 0 | 151 | | { |
| 0 | 152 | | section.RemoveAmendment(amendment); |
| 0 | 153 | | } |
| | 154 | |
|
| 0 | 155 | | foreach(var changeAmendment in section.ChangeAmendments.Where(n => n.TargetSectionId == paragraph.OperativeP |
| 0 | 156 | | { |
| 0 | 157 | | section.RemoveAmendment(changeAmendment); |
| 0 | 158 | | } |
| | 159 | |
|
| 0 | 160 | | foreach(var deleteAmendment in section.DeleteAmendments.Where(n => n.TargetSectionId == paragraph.OperativeP |
| 0 | 161 | | { |
| 0 | 162 | | section.RemoveAmendment(deleteAmendment); |
| 0 | 163 | | } |
| | 164 | |
|
| 0 | 165 | | foreach(var moveAmendment in section.MoveAmendments.Where(n => n.TargetSectionId == paragraph.OperativeParag |
| 0 | 166 | | { |
| 0 | 167 | | section.RemoveAmendment(moveAmendment); |
| 0 | 168 | | } |
| 0 | 169 | | } |
| | 170 | |
|
| | 171 | | /// <summary> |
| | 172 | | /// Will return a list of suple with all information about the operative paragraphs. |
| | 173 | | /// </summary> |
| | 174 | | /// <param name="resolution"></param> |
| | 175 | | /// <returns></returns> |
| | 176 | | public static List<(string id, string path, string text)> GetRealOperativeParagraphsInfo(this Resolution resolut |
| 0 | 177 | | { |
| 0 | 178 | | var list = new List<(string id, string path, string text)>(); |
| 0 | 179 | | var realParagraphs = resolution.OperativeSection.Paragraphs.Where(n => !n.IsVirtual); |
| 0 | 180 | | int index = 1; |
| 0 | 181 | | foreach (var paragraph in realParagraphs) |
| 0 | 182 | | { |
| 0 | 183 | | string prePath = index.ToString(); |
| 0 | 184 | | AddRealOperativeParagraphInfoRec(prePath, paragraph, list); |
| 0 | 185 | | index++; |
| 0 | 186 | | } |
| 0 | 187 | | return list; |
| 0 | 188 | | } |
| | 189 | |
|
| | 190 | | /// <summary> |
| | 191 | | /// Recursive function used by GetRealOperativeParagraphsInfo |
| | 192 | | /// </summary> |
| | 193 | | /// <param name="prePath"></param> |
| | 194 | | /// <param name="paragraph"></param> |
| | 195 | | /// <param name="list"></param> |
| | 196 | | private static void AddRealOperativeParagraphInfoRec(string prePath, OperativeParagraph paragraph, List<(string |
| 0 | 197 | | { |
| 0 | 198 | | var newElement = (id: paragraph.OperativeParagraphId, path: prePath, text: paragraph.Text); |
| 0 | 199 | | list.Add(newElement); |
| 0 | 200 | | if (paragraph.Children != null && paragraph.Children.Any()) |
| 0 | 201 | | { |
| 0 | 202 | | var realParagraphs = paragraph.Children.Where(n => !n.IsVirtual); |
| 0 | 203 | | int index = 1; |
| 0 | 204 | | prePath += "."; |
| 0 | 205 | | int level = prePath.Count(n => n == '.'); |
| 0 | 206 | | foreach (var childParagraph in realParagraphs) |
| 0 | 207 | | { |
| 0 | 208 | | var newPath = prePath; |
| 0 | 209 | | if (level == 1 || level % 4 == 1) newPath += (index - 1).ToLetter(); |
| 0 | 210 | | else if (level == 2 || level % 5 == 2) newPath += (index).ToRoman().ToLower(); |
| 0 | 211 | | AddRealOperativeParagraphInfoRec(newPath, childParagraph, list); |
| 0 | 212 | | index++; |
| 0 | 213 | | } |
| 0 | 214 | | } |
| 0 | 215 | | } |
| | 216 | |
|
| | 217 | | /// <summary> |
| | 218 | | /// Inserts a paragraph into the real position. The index you give here is the one that you would get by blockin |
| | 219 | | /// For example: 1, (2), (3), 4, (5) where paragraph 2,3 and 5 are virtual, then the assumption is that paragrap |
| | 220 | | /// the case. You would pass 2 to this function if you want to add a paragraph between 4 but before 5. |
| | 221 | | /// </summary> |
| | 222 | | /// <param name="section"></param> |
| | 223 | | /// <param name="paragraph"></param> |
| | 224 | | /// <param name="targetIndex"></param> |
| | 225 | | /// <param name="parentParagraph"></param> |
| | 226 | | /// <returns></returns> |
| | 227 | | public static int InsertIntoRealPosition(this OperativeSection section, OperativeParagraph paragraph, int target |
| 0 | 228 | | { |
| 0 | 229 | | if (parentParagraph == null) |
| 0 | 230 | | { |
| 0 | 231 | | if (targetIndex > section.Paragraphs.Count) targetIndex = section.Paragraphs.Count; |
| 0 | 232 | | section.Paragraphs.Insert(targetIndex, paragraph); |
| 0 | 233 | | } |
| | 234 | | else |
| 0 | 235 | | { |
| 0 | 236 | | if (section.FindOperativeParagraph(parentParagraph.OperativeParagraphId) == null) |
| 0 | 237 | | throw new MUNity.Exceptions.Resolution.OperativeParagraphNotFoundException("Target parent Paragraph |
| | 238 | |
|
| 0 | 239 | | parentParagraph.Children.Insert(targetIndex, paragraph); |
| 0 | 240 | | } |
| 0 | 241 | | return targetIndex; |
| 0 | 242 | | } |
| | 243 | |
|
| | 244 | | /// <summary> |
| | 245 | | /// Returns the displayed Index name of a Paragraph for example |
| | 246 | | /// 1, 2, 2.a, 2.a.i etc. |
| | 247 | | /// </summary> |
| | 248 | | /// <param name="section"></param> |
| | 249 | | /// <param name="paragraphId"></param> |
| | 250 | | /// <returns></returns> |
| | 251 | | public static string GetIndexNameOfOperativeParagraph(this OperativeSection section, string paragraphId) |
| 0 | 252 | | { |
| 0 | 253 | | if (string.IsNullOrEmpty(paragraphId) ||section == null) |
| 0 | 254 | | return ""; |
| | 255 | |
|
| 0 | 256 | | var path = section.GetOperativeParagraphPath(paragraphId); |
| 0 | 257 | | var numbers = new List<int>(); |
| 0 | 258 | | OperativeParagraph parent = null; |
| 0 | 259 | | foreach (var paragraph in path) |
| 0 | 260 | | { |
| 0 | 261 | | if (parent == null) |
| 0 | 262 | | { |
| 0 | 263 | | numbers.Add(section.Paragraphs.Where(n => !n.IsVirtual).ToList().IndexOf(paragraph)); |
| 0 | 264 | | } |
| | 265 | | else |
| 0 | 266 | | { |
| 0 | 267 | | numbers.Add(parent.Children.Where(n => !n.IsVirtual).ToList().IndexOf(paragraph)); |
| 0 | 268 | | } |
| 0 | 269 | | parent = paragraph; |
| 0 | 270 | | } |
| 0 | 271 | | return numbers.ToArray().ToPathname(); |
| 0 | 272 | | } |
| | 273 | |
|
| | 274 | | /// <summary> |
| | 275 | | /// Returns the Index of a paragraph inside its parent. |
| | 276 | | /// </summary> |
| | 277 | | /// <param name="section"></param> |
| | 278 | | /// <param name="paragraph"></param> |
| | 279 | | /// <returns></returns> |
| | 280 | | public static int IndexOfParagraph(this OperativeSection section, OperativeParagraph paragraph) |
| 0 | 281 | | { |
| 0 | 282 | | int index = section.Paragraphs.IndexOf(paragraph); |
| 0 | 283 | | if (index != -1) return index; |
| 0 | 284 | | var path = section.GetOperativeParagraphPath(paragraph.OperativeParagraphId); |
| 0 | 285 | | var parentElement = path[path.Count - 1]; |
| 0 | 286 | | return parentElement.Children.IndexOf(paragraph); |
| 0 | 287 | | } |
| | 288 | |
|
| | 289 | |
|
| | 290 | | /// <summary> |
| | 291 | | /// Returns a list of all Ids of all operative paragraphs that exist. |
| | 292 | | /// </summary> |
| | 293 | | /// <param name="section"></param> |
| | 294 | | /// <returns></returns> |
| | 295 | | public static List<string> GetAllOperativeParagraphIds(this OperativeSection section) |
| 0 | 296 | | { |
| 0 | 297 | | var list = new List<string>(); |
| 0 | 298 | | list.AddRange(section.Paragraphs.Select(n => n.OperativeParagraphId)); |
| 0 | 299 | | foreach(var paragraph in section.Paragraphs) |
| 0 | 300 | | { |
| 0 | 301 | | AddAllChildrenRecursive(paragraph, list); |
| 0 | 302 | | } |
| 0 | 303 | | return list; |
| 0 | 304 | | } |
| | 305 | |
|
| | 306 | | /// <summary> |
| | 307 | | /// Will execute a Linq Where inside all operative paragraphs including Child paragraphs. |
| | 308 | | /// </summary> |
| | 309 | | /// <param name="operativeSection"></param> |
| | 310 | | /// <param name="predicate"></param> |
| | 311 | | /// <returns></returns> |
| | 312 | | public static List<OperativeParagraph> WhereParagraph(this OperativeSection operativeSection, Func<OperativePara |
| 0 | 313 | | { |
| 0 | 314 | | var list = new List<OperativeParagraph>(); |
| 0 | 315 | | list.AddRange(operativeSection.Paragraphs.Where(predicate)); |
| 0 | 316 | | foreach(var paragraph in operativeSection.Paragraphs) |
| 0 | 317 | | { |
| 0 | 318 | | DeepWhere(paragraph, predicate, list); |
| 0 | 319 | | } |
| 0 | 320 | | return list; |
| 0 | 321 | | } |
| | 322 | |
|
| | 323 | | /// <summary> |
| | 324 | | /// needed fore WhereParagraph. |
| | 325 | | /// </summary> |
| | 326 | | /// <param name="parentParagraph"></param> |
| | 327 | | /// <param name="predicate"></param> |
| | 328 | | /// <param name="resultList"></param> |
| | 329 | | private static void DeepWhere(OperativeParagraph parentParagraph, Func<OperativeParagraph, bool> predicate, List |
| 0 | 330 | | { |
| 0 | 331 | | if (parentParagraph.Children != null && parentParagraph.Children.Any()) |
| 0 | 332 | | { |
| 0 | 333 | | resultList.AddRange(parentParagraph.Children.Where(predicate)); |
| 0 | 334 | | foreach(var child in parentParagraph.Children) |
| 0 | 335 | | { |
| 0 | 336 | | DeepWhere(child, predicate, resultList); |
| 0 | 337 | | } |
| 0 | 338 | | } |
| 0 | 339 | | } |
| | 340 | |
|
| | 341 | | /// <summary> |
| | 342 | | /// Will make a Linq FirstOrDefault in all operative paragraphs including child paragraphs. |
| | 343 | | /// </summary> |
| | 344 | | /// <param name="operativeSection"></param> |
| | 345 | | /// <param name="predicate"></param> |
| | 346 | | /// <returns></returns> |
| | 347 | | public static OperativeParagraph FirstOrDefault(this OperativeSection operativeSection, Func<OperativeParagraph, |
| 0 | 348 | | { |
| 0 | 349 | | var result = operativeSection.Paragraphs.FirstOrDefault(predicate); |
| 0 | 350 | | if (result != null) return result; |
| 0 | 351 | | foreach (var s in operativeSection.Paragraphs) |
| 0 | 352 | | { |
| 0 | 353 | | result = DeepFirstOrDefault(s, predicate); |
| 0 | 354 | | if (result != null) return result; |
| 0 | 355 | | } |
| 0 | 356 | | return null; |
| 0 | 357 | | } |
| | 358 | |
|
| | 359 | | /// <summary> |
| | 360 | | /// used by FirstOrDefault |
| | 361 | | /// </summary> |
| | 362 | | /// <param name="paragraph"></param> |
| | 363 | | /// <param name="predicate"></param> |
| | 364 | | /// <returns></returns> |
| | 365 | | private static OperativeParagraph DeepFirstOrDefault(this OperativeParagraph paragraph, Func<OperativeParagraph, |
| 0 | 366 | | { |
| 0 | 367 | | var result = paragraph.Children.FirstOrDefault(predicate); |
| 0 | 368 | | if (result != null) return result; |
| 0 | 369 | | foreach (var child in paragraph.Children) |
| 0 | 370 | | { |
| 0 | 371 | | return DeepFirstOrDefault(child, predicate); |
| | 372 | | } |
| 0 | 373 | | return null; |
| 0 | 374 | | } |
| | 375 | |
|
| | 376 | |
|
| | 377 | | #region function linking |
| | 378 | | /// <summary> |
| | 379 | | /// Gets the Index/Pathname of an operative paragraph. |
| | 380 | | /// </summary> |
| | 381 | | /// <param name="section"></param> |
| | 382 | | /// <param name="paragraph"></param> |
| | 383 | | /// <returns></returns> |
| 0 | 384 | | public static string GetIndexNameOfOperativeParagraph(this OperativeSection section, OperativeParagraph paragrap |
| | 385 | | #endregion |
| | 386 | |
|
| | 387 | | #region internal |
| | 388 | | /// <summary> |
| | 389 | | /// Adds all children to a list to create one List of all paragraphIds. |
| | 390 | | /// </summary> |
| | 391 | | /// <param name="paragraph"></param> |
| | 392 | | /// <param name="list"></param> |
| | 393 | | private static void AddAllChildrenRecursive(OperativeParagraph paragraph, List<string> list) |
| 0 | 394 | | { |
| 0 | 395 | | if (paragraph.Children != null && paragraph.Children.Any()) |
| 0 | 396 | | { |
| 0 | 397 | | list.AddRange(paragraph.Children.Select(n => n.OperativeParagraphId)); |
| 0 | 398 | | foreach(var child in paragraph.Children) |
| 0 | 399 | | { |
| 0 | 400 | | AddAllChildrenRecursive(child, list); |
| 0 | 401 | | } |
| 0 | 402 | | } |
| 0 | 403 | | } |
| | 404 | | #endregion |
| | 405 | |
|
| | 406 | | /// <summary> |
| | 407 | | /// Returns a Flat List of all the Operative Paragraphs in one Level, meaning all Child Paragraphs will also |
| | 408 | | /// be part of this list! |
| | 409 | | /// </summary> |
| | 410 | | /// <param name="section"></param> |
| | 411 | | /// <returns></returns> |
| | 412 | | public static List<OperativeParagraph> GetAllParagraphs(this OperativeSection section) |
| 0 | 413 | | { |
| 0 | 414 | | var list = new List<OperativeParagraph>(); |
| 0 | 415 | | foreach(var paragraph in section.Paragraphs) |
| 0 | 416 | | { |
| 0 | 417 | | TraverseParagraph(paragraph, list); |
| 0 | 418 | | } |
| 0 | 419 | | return list; |
| 0 | 420 | | } |
| | 421 | |
|
| | 422 | | private static void TraverseParagraph(OperativeParagraph paragraph, List<OperativeParagraph> targetList) |
| 0 | 423 | | { |
| 0 | 424 | | targetList.Add(paragraph); |
| 0 | 425 | | if (paragraph.Children != null && paragraph.Children.Any()) |
| 0 | 426 | | { |
| 0 | 427 | | targetList.AddRange(paragraph.Children); |
| 0 | 428 | | foreach(var child in paragraph.Children) |
| 0 | 429 | | { |
| 0 | 430 | | TraverseParagraph(child, targetList); |
| 0 | 431 | | } |
| 0 | 432 | | } |
| 0 | 433 | | } |
| | 434 | |
|
| | 435 | | /// <summary> |
| | 436 | | /// Returns all Amendments in order of |
| | 437 | | /// </summary> |
| | 438 | | /// <param name="section"></param> |
| | 439 | | /// <returns></returns> |
| | 440 | | public static IEnumerable<AbstractAmendment> GetOrderedAmendments(this OperativeSection section) |
| 0 | 441 | | { |
| 0 | 442 | | var list = new List<AbstractAmendment>(); |
| 0 | 443 | | var allParagraphs = section.GetAllParagraphs(); |
| 0 | 444 | | foreach (var paragraph in allParagraphs) |
| 0 | 445 | | { |
| 0 | 446 | | var deleteAmendments = section.DeleteAmendments.Where(n => n.TargetSectionId == |
| 0 | 447 | | paragraph.OperativeParagraphId).OrderBy(n => n.SubmitTime).ToList(); |
| 0 | 448 | | if (deleteAmendments.Any()) |
| 0 | 449 | | list.AddRange(deleteAmendments); |
| | 450 | |
|
| 0 | 451 | | var changeAmendments = section.ChangeAmendments.Where(n => n.TargetSectionId == |
| 0 | 452 | | paragraph.OperativeParagraphId).OrderBy(n => n.SubmitTime).ToList(); |
| 0 | 453 | | if (changeAmendments.Any()) |
| 0 | 454 | | list.AddRange(changeAmendments); |
| | 455 | |
|
| 0 | 456 | | var moveAmendments = section.MoveAmendments.Where(n => n.TargetSectionId == |
| 0 | 457 | | paragraph.OperativeParagraphId).OrderBy(n => n.SubmitTime).ToList(); |
| 0 | 458 | | if (moveAmendments.Any()) |
| 0 | 459 | | list.AddRange(moveAmendments); |
| 0 | 460 | | } |
| | 461 | |
|
| 0 | 462 | | list.AddRange(section.AddAmendments); |
| 0 | 463 | | allParagraphs.Clear(); |
| 0 | 464 | | return list; |
| 0 | 465 | | } |
| | 466 | |
|
| | 467 | | /// <summary> |
| | 468 | | /// Returns all Amendments starting with the Add Amendments then ChangeAmendments, DeleteAmendments and MoveAmen |
| | 469 | | /// </summary> |
| | 470 | | /// <param name="section"></param> |
| | 471 | | /// <returns></returns> |
| | 472 | | public static IEnumerable<AbstractAmendment> GetAllAmendments(this OperativeSection section) |
| 0 | 473 | | { |
| | 474 | |
|
| 0 | 475 | | return section.AddAmendments |
| 0 | 476 | | .Union<AbstractAmendment>(section.ChangeAmendments) |
| 0 | 477 | | .Union(section.DeleteAmendments) |
| 0 | 478 | | .Union(section.MoveAmendments); |
| 0 | 479 | | } |
| | 480 | | } |
| | 481 | | } |