public bool TryAdd(IToBeLearnedItem item) { //Check if an item with this question already exists (don't want duplicates!) var itemQuestion = item.GetQuestion(); if (_loadedItems.Any(m => string.Compare(m.GetTheQuestion(), itemQuestion, true) == 0)) { return(false); } //Generate a new statistics item for this var wordStats = new WordStatistics { DateLearned = DateTime.Now, NumberOfTimesAnsweredCorrectly = 0, NumberOfTimesAsked = 0, UniqueId = item.UniqueId, }; _loadedItems.Add(new MemorisableItem(item, wordStats)); _wordSerialiser.AddItemForSerialisation(item); //Probably shouldn't rewrite the whole thing after every new item added, but works for now WriteWordsToStorage(); WriteStatsToStorage(); return(true); }
public MemorisableItem(IToBeLearnedItem toBeLearnedItem, WordStatistics stats) { _toBeLearned = toBeLearnedItem; statistics = stats; }