private static ImportNotificationSummary CreateImportNotifiationSummary(ImportNotificationStatus status) { var wasteType = new WasteType() { EwcCodes = new WasteCodeSelection() { WasteCodes = CreateEwcCodes() }, YCodes = new WasteCodeSelection() { WasteCodes = CreateYCodes() }, HCodes = new WasteCodeSelection() { WasteCodes = CreateHCodes() }, UnClasses = new WasteCodeSelection() { WasteCodes = CreateUnClasses() } }; var summary = new ImportNotificationSummary() { Id = Guid.NewGuid(), Type = NotificationType.Recovery, Status = status, Number = "GB123", WasteType = wasteType }; return(summary); }
public SummaryTableContainerViewModel(ImportNotificationSummary details, bool canChangeNumberOfShipments, bool canChangeEntryExitPoint, bool canChangeWasteTypes, bool canChangeWasteOperation, bool canEditContactDetails) { Details = details; ShowChangeLinks = details.Status == ImportNotificationStatus.NotificationReceived; ShowChangeNumberOfShipmentsLink = canChangeNumberOfShipments && details.Status == ImportNotificationStatus.Consented; ShowChangeEntryExitPointLink = canChangeEntryExitPoint && details.Status != ImportNotificationStatus.New && details.Status != ImportNotificationStatus.NotificationReceived && details.Status != ImportNotificationStatus.FileClosed; ShowChangeWasteTypesLink = canChangeWasteTypes && EditableStatus(details.Status); ShowChangeWasteOperationLink = canChangeWasteOperation && EditableStatus(details.Status); CanEditContactDetails = canEditContactDetails && EditableStatus(details.Status); if (details.WasteType != null) { var ewcCodesOrdered = details.WasteType.EwcCodes.WasteCodes.OrderBy(w => w.Name).ToList(); var ycodesOrdered = details.WasteType.YCodes.WasteCodes.OrderBy(w => Regex.Match(!string.IsNullOrEmpty(w.Name) ? w.Name : string.Empty, @"(\D+)").Value).ThenBy(w => { double val; double.TryParse(Regex.Match(!string.IsNullOrEmpty(w.Name) ? w.Name : string.Empty, @"(\d+(\.\d*)?|\.\d+)").Value, out val); return(val); }).ToList(); var hcodesOrdered = details.WasteType.HCodes.WasteCodes.OrderBy(w => Regex.Match(!string.IsNullOrEmpty(w.Name) ? w.Name : string.Empty, @"(\D+)").Value).ThenBy(w => { double val; double.TryParse(Regex.Match(!string.IsNullOrEmpty(w.Name) ? w.Name : string.Empty, @"(\d+(\.\d*)?|\.\d+)").Value, out val); return(val); }).ToList(); var unclassesOrdered = details.WasteType.UnClasses.WasteCodes.OrderBy(w => w.Name).ToList(); Details.WasteType.EwcCodes.WasteCodes = ewcCodesOrdered; Details.WasteType.YCodes.WasteCodes = ycodesOrdered; Details.WasteType.HCodes.WasteCodes = hcodesOrdered; Details.WasteType.UnClasses.WasteCodes = unclassesOrdered; } }