Exemple #1
0
        public void UpdateLevel(InstrumentLevel instrumentLevel)
        {
            InstrumentLevel currentLevelVolume = (Levels ?? new InstrumentLevel[0])
                                                 .FirstOrDefault(o => !string.IsNullOrEmpty(instrumentLevel.Id)
                    ? o.Id == instrumentLevel.Id
                    : o.Number == instrumentLevel.Number);

            if (currentLevelVolume == null)
            {
                throw new InvalidOperationException("The level does not exists");
            }

            if (!string.IsNullOrEmpty(instrumentLevel.Id) && Levels?
                .Any(o => o.Id != instrumentLevel.Id && o.Number == instrumentLevel.Number) == true)
            {
                throw new InvalidOperationException("The level already exists");
            }

            currentLevelVolume.Number = instrumentLevel.Number;
            currentLevelVolume.Volume = instrumentLevel.Volume;
            currentLevelVolume.Markup = instrumentLevel.Markup;

            // ReSharper disable once AssignNullToNotNullAttribute
            Levels = Levels
                     .OrderBy(o => o.Number)
                     .ToArray();
        }
Exemple #2
0
        public void AddLevel(InstrumentLevel instrumentLevel)
        {
            if (Levels?.Any(o => o.Number == instrumentLevel.Number) == true)
            {
                throw new InvalidOperationException("The level already exists");
            }

            instrumentLevel.Id = Guid.NewGuid().ToString();

            Levels = (Levels ?? new InstrumentLevel[0])
                     .Union(new[] { instrumentLevel })
                     .OrderBy(o => o.Number)
                     .ToArray();
        }
Exemple #3
0
 public Instrument()
 {
     Levels           = new InstrumentLevel[0];
     CrossInstruments = new CrossInstrument[0];
 }