Exemplo n.º 1
0
        public Flashcard AddFlashcard(int flashcardTemplateID, DbContext context = null)
        {
            Flashcard newValue;

            if (_flashcards != null)
            {
                newValue = new Flashcard(flashcardTemplateID);
                _flashcards.Add(newValue);
            }
            else if (context == null)
            {
                throw new ArgumentNullException(nameof(context), $"You must provide a context if the the '{nameof(Flashcards)}' collection isn't valid");
            }
            else if (context.Entry(this).IsKeySet)
            {
                newValue = new Flashcard(flashcardTemplateID, NoteID);
                context.Add(newValue);
            }
            else
            {
                throw new InvalidOperationException("Could not add a new Note Type Value");
            }

            return(newValue);
        }
Exemplo n.º 2
0
 public void RemoveFlashcard(Flashcard value, DbContext context = null)
 {
     if (_flashcards != null)
     {
         _flashcards.Remove(value);
     }
     else if (context == null)
     {
         throw new ArgumentNullException(nameof(context), $"You must provide a context if the the '{nameof(NoteValues)}' collection isn't valid");
     }
     else if (context.Entry(this).IsKeySet)
     {
         context.Remove(value);
     }
     else
     {
         throw new InvalidOperationException("Could not remove a new Note Type Value");
     }
 }