Beispiel #1
0
        private Unit GetUnit(string unitGroupId, string unitId)
        {
            var unitGroup = UnitGroups
                            .FirstOrDefault(ug => ug.GroupIdentifier == unitGroupId);

            if (unitGroup == null)
            {
                throw new ExpectedException($"'{unitGroupId}' is not a known unit group.");
            }

            var unit = unitGroup
                       .Units
                       .FirstOrDefault(u => u.UnitIdentifier == unitId);

            if (unit == null)
            {
                throw new ExpectedException($"'{unitId}' is not part of the '{unitGroup.GroupIdentifier}' unit group.");
            }

            return(unit);
        }
 public static UnitGroup GetUnitGroup(this UnitGroups source, string id)
 {
     return(source.FirstOrDefault(l => l.Id == id));
 }