Ejemplo n.º 1
0
 public OperationCodesViewModel(NotificationType type, IEnumerable <OperationCode> selectedCodes)
 {
     this.NotificationType = type;
     PossibleCodes         = OperationCodeMetadata.GetCodesForOperation(type)
                             .Select(c => new KeyValuePairViewModel <OperationCode, bool>(c, selectedCodes.Contains(c)))
                             .ToList();
 }
        public void SetDetails(NotificationDetails details)
        {
            ImportNotificationId = details.ImportNotificationId;
            NotificationType     = details.NotificationType;

            Codes =
                OperationCodeMetadata.GetCodesForOperation(details.NotificationType)
                .Select(c => new KeyValuePairViewModel <OperationCode, bool>(c, SelectedCodes.Contains(c)))
                .ToList();
        }
        public UpdateWasteOperationViewModel(WasteOperationData data)
        {
            ImportNotificationId = data.Details.ImportNotificationId;
            NotificationType     = data.Details.NotificationType;

            var selectedCodes = data.OperationCodes ?? new OperationCode[0];

            Codes =
                OperationCodeMetadata.GetCodesForOperation(data.Details.NotificationType)
                .Select(c => new KeyValuePairViewModel <OperationCode, bool>(c, selectedCodes.Contains(c)))
                .ToList();

            TechnologyEmployed = data.TechnologyEmployed;
        }
Ejemplo n.º 4
0
        public void SetOperationCodes(IEnumerable <OperationCode> operationCodes)
        {
            var operationCodesList = operationCodes as IList <OperationCode> ?? operationCodes.ToList();

            if (operationCodesList.Any(p => !OperationCodeMetadata.IsCodeOfOperationType(p, NotificationType)))
            {
                throw new InvalidOperationException(string.Format("This notification {0} can only have {1} operation codes.", Id, NotificationType));
            }

            OperationInfosCollection.Clear();

            foreach (var operationCode in operationCodesList)
            {
                OperationInfosCollection.Add(new OperationInfo(operationCode));
            }
        }
Ejemplo n.º 5
0
        public static OperationCodesList CreateForNotification(ImportNotification notification,
                                                               IEnumerable <OperationCode> operationCodes)
        {
            var codes = operationCodes as OperationCode[] ?? operationCodes.ToArray();

            if (!codes.Any())
            {
                throw new ArgumentException("Operation codes can't be empty", "operationCodes");
            }

            if (!codes.IsUnique())
            {
                throw new ArgumentException("Operation codes must be unique", "operationCodes");
            }

            if (codes.Any(p => !OperationCodeMetadata.IsCodeOfOperationType(p, notification.NotificationType)))
            {
                throw new ArgumentException(
                          string.Format("This notification {0} can only have {1} operation codes.",
                                        notification.Id, notification.NotificationType), "operationCodes");
            }

            return(new OperationCodesList(codes));
        }
Ejemplo n.º 6
0
        private static bool BeOfSameType(OperationCode[] operationCodes)
        {
            var types = operationCodes.Select(x => x).ToList();

            return(types.Skip(1).All(p => OperationCodeMetadata.GetCodeType(p) == OperationCodeMetadata.GetCodeType(types.First())));
        }