Exemple #1
0
        public NoteFieldValue AddValue(int noteTypeFieldDefinitionId, string noteValue, DbContext context = null)
        {
            NoteFieldValue newValue;

            if (_noteValues != null)
            {
                newValue = new NoteFieldValue(noteTypeFieldDefinitionId, noteValue);
                _noteValues.Add(newValue);
            }
            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)
            {
                newValue = new NoteFieldValue(noteTypeFieldDefinitionId, noteValue, NoteID);
                context.Add(newValue);
            }
            else
            {
                throw new InvalidOperationException("Could not add a new Note Type Value");
            }

            return(newValue);
        }
Exemple #2
0
 public void RemoveValue(NoteFieldValue value, DbContext context = null)
 {
     if (_noteValues != null)
     {
         _noteValues.Remove(value);
     }
     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)
     {
         context.Remove(value);
     }
     else
     {
         throw new InvalidOperationException("Could not remove a new Note Type Value");
     }
 }