Beispiel #1
0
 internal static void ItemDuplicate(TeachingAide teachingAide)
 {
     if (teachingAide.Items_TItems != null)
     {
         if (teachingAide.Items_TItems.Count > 1)
         {
             throw new ArgumentException("Cannot add more than one Item to teachingAide at a time");
         }
         else
         {
             if (teachingAide.Items_TItems.Count != teachingAide.Items_TItems.Distinct().Count())
             {
                 throw new ArgumentException("Game already contains specified Id, cannot add duplicate Id to TeachingAide");
             }
         }
     }
 }
Beispiel #2
0
 internal static void ItemDuplicate(TeachingAide teachingAide, TeachingAide oldTeachingAide)
 {
     if (teachingAide.Items_TItems != null)
     {
         if (teachingAide.Items_TItems.Count > 1)
         {
             throw new ArgumentException("Cannot add more than one Item to teachingAide at a time");
         }
         if (teachingAide.Items_TItems.Count != teachingAide.Items_TItems.Distinct().Count())
         {
             throw new ArgumentException("Game already contains specified Id, cannot add duplicate Id to TeachingAide");
         }
         if (oldTeachingAide.Items_TItems.Any(b =>
         {
             var firstOrDefault = teachingAide.Items_TItems.FirstOrDefault();
             return(firstOrDefault != null && b.Id == firstOrDefault.Id);
         }))
         {
             throw new ArgumentException("A TeachingAide exists that already contains specified Id, cannot add duplicate Id to TeachingAide");
         }
     }
 }