public async Task <bool> Handle(WordFamiliarityUpsertBatch request, CancellationToken cancellationToken) { new WordFamiliarityUpsertBatchValidator().ValidateAndThrow(request); await WordSelector.EnsureWordsCreated(DB, Mapper, request.Words, cancellationToken); await DB.Unsafe.SaveChangesAsync(cancellationToken); if (request.Level == 0) { // Not sure why but this doesn't run. // System.ArgumentException : Field '_queryCompiler' defined on type 'Microsoft.EntityFrameworkCore.Query.Internal.EntityQueryProvider' is not a field on the target object which is of type 'LinqKit.ExpandableQueryProvider`1[ReadABit.Infrastructure.Models.WordFamiliarity]'. // await DB.WordFamiliaritiesOfUser(request.UserId) // .OfWords(request.Words) // .DeleteAsync(cancellationToken); var wordFamiliarityIds = await DB.WordFamiliaritiesOfUser(request.UserId) .OfWords(request.Words) .Select(wf => wf.Id) .ToListAsync(cancellationToken); await DB.WordFamiliaritiesOfUser(request.UserId) .Where(wf => wordFamiliarityIds.Contains(wf.Id)) .DeleteAsync(cancellationToken); return(true); } await UpsertWordFamiliarity(request, cancellationToken); return(true); }
public static IQueryable <Word> OfWord(this IQueryable <Word> query, WordSelector selector) { return(query .Where(w => w.LanguageCode == selector.LanguageCode && w.Expression == selector.Expression.Normalize() )); }
public static IQueryable <T> OfWord <T>(this IQueryable <T> query, WordSelector selector) where T : IOfWord { return(query .Where(wd => wd.Word.LanguageCode == selector.LanguageCode && wd.Word.Expression == selector.Expression.Normalize() )); }
public void ShouldReturnOnlyAlphabeticValues_WhenIsFilteringAlphabeticIsTrueAndOthersAreSetToFalse() { // Given var textRange = CreateTextRange("hello 10! how are you? I am 55 years old."); var underTest = new WordSelector(); underTest.ApplyAttributes(new[] { new SelectorAttribute("alphabetic", true) }); // When var result = underTest.SelectElement(textRange).Select(range => range.GetText()); // Then Assert.That(result, Is.EquivalentTo(new[] { "hello", "how", "are", "you", "I", "am", "years", "old" })); }
public void ShouldReturnSeparatedWordsOfSpecifiedText_WhenEveryAttributeHasDefaultValue() { // Given var textRange = CreateTextRange("hello world, how\nare\r\nyou?!Fine (thanks)."); var underTest = new WordSelector(); // When var result = underTest.SelectElement(textRange).Select(range => range.GetText()); // Then Assert.That(result, Is.EquivalentTo(new[] { "hello", "world", "how", "are", "you", "Fine", "thanks" })); }
public static Task <Guid> IdOfWord(this IQueryable <Word> query, WordSelector selector, CancellationToken cancellationToken) { return(query.OfWord(selector) .Select(w => w.Id) .SingleOrDefaultAsync(cancellationToken: cancellationToken)); }
public void OnPointerExit(PointerEventData eventData) { backgroundImage.color = UI_Manager.WordObjectNormalColor; WordSelector.TogglePopupCurentLink(string.Empty); }
public void WordList_OnlyAcceptsFiveLetters() { WordSelector wordSelector = new WordSelector(); var selectedWord = wordSelector.SelectWord(new List<string> { "bread", "take", "maples" }); Assert.Equal("BREAD", selectedWord); }
public void OnPointerEnter(PointerEventData eventData) { backgroundImage.color = UI_Manager.WordObjectHighlightColor; WordSelector.TogglePopupCurentLink(word); }
public void WordList_EmptyList_ReturnsEmpty() { WordSelector wordSelector = new WordSelector(); var selectedWord = wordSelector.SelectWord(new List<string>()); Assert.Equal("", selectedWord); }
public void WordList_IgnoresCase() { WordSelector wordSelector = new WordSelector(); var selectedWord = wordSelector.SelectWord(new List<string> { "bread" }); Assert.Equal("BREAD", selectedWord); }
public void SelectedWord_SelectsWordFromList() { WordSelector wordSelector = new WordSelector(); var selectedWord = wordSelector.SelectWord(new List<string> { "bread", "apple" }); Assert.NotNull(selectedWord); }
public void SelectedWord_DoesNotContainMultipleLetters() { WordSelector wordSelector = new WordSelector(); var selectedWord = wordSelector.SelectWord(new List<string> { "apple", "bread" }); Assert.Equal("BREAD", selectedWord); }
public Setting(WordSelector.WordSelector selector) { this.selector = selector; InitializeComponent(); }
public CommandChangeDistribution(WordSelector.WordSelector selector) : base(".distribution","change distribution (left , right , median)") { this.selector = selector; }
public CommandResetRandomSequence(WordSelector.WordSelector selector) : base(".reset","reset random sequence") { this.selector=selector; }