public async Task <ActionResult <Word> > PostWord(Shared.Word word) { var newWord = new Domain.Word() { Text = word.Text }; _context.Word.Add(newWord); await _context.SaveChangesAsync(); return(CreatedAtAction("GetWord", new { text = word.Text }, _mapper.Map <Shared.Word>(newWord))); }
private void DisplayOneAnswerWord(Domain.Word currentWord) { _location = this.GetType().Name + "." + MethodBase.GetCurrentMethod().Name; _logger.OpenSection(_location); this.lbQuote.Text = currentWord.Quote.Character + "「" + currentWord.Quote.Text + "」"; this.lbWord.Text = currentWord.Kanji + "【" + currentWord.Kana + "】"; this.lbDefinitionOrTranslation.Text = currentWord.Translation; btnNext.Visible = false; btnMasteryUp.Visible = btnMasteryDown.Visible = true; // TODO better logging _logger.CloseSection(_location); }
private Domain.Word GetOneWord(Domain.Word currentWord) { _location = this.GetType().Name + "." + MethodBase.GetCurrentMethod().Name; _logger.OpenSection(_location); Domain.Word returnedWord; do { var maxId = Math.Min((int)_numberOfCurrentWords / 2, _wordsToStudy.Count - 1); wordIndex = new Random().Next(0, maxId); returnedWord = _wordsToStudy[wordIndex]; }while (currentWord != null && currentWord.Id == returnedWord.Id); // TODO better logging _logger.CloseSection(_location); return(returnedWord); }
private void NextStep() { UpdateEveryStepLabels(); CurrentStep = DetermineNextStep(); switch (CurrentStep) { case Step.Question: CurrentWord = GetOneWord(CurrentWord); DisplayOneQuestionWord(CurrentWord); break; case Step.Answer: DisplayOneAnswerWord(CurrentWord); break; default: var ex = new Exception("Invalid step '" + CurrentStep + "'. Aborting all the things"); _logger.Error(ex); throw ex; } }
public ActionResult Index(Domain.Word input) { Domain.Word output = _wordService.Convert(input); return(Json(output.Number)); }
private void DisplayOneQuestionWord(Domain.Word currentWord) { _location = this.GetType().Name + "." + MethodBase.GetCurrentMethod().Name; _logger.OpenSection(_location); var currentQuote = currentWord.Quote; var currentSource = currentQuote.Source; // Colored mastery rectangle CurrentStudyingType = currentWord.ReadingMastery < 100 ? StudyingType.Reading : currentWord.KanjiMastery < 100 ? StudyingType.Kanji : StudyingType.Translation; /* * if (mastery < 31) * { * this.lblIdMastery.BackColor = Color.LightSalmon; * } * else if (mastery < 61) * { * this.lblIdMastery.BackColor = Color.LightYellow; * } * else * { * this.lblIdMastery.BackColor = Color.LightGreen; * } */ if (CurrentStudyingType == StudyingType.Reading) { this.lblIdMastery.BackColor = Color.LightSalmon; } else if (CurrentStudyingType == StudyingType.Kanji) { this.lblIdMastery.BackColor = Color.LightYellow; } else { this.lblIdMastery.BackColor = Color.LightGreen; } var mastery = currentWord.ReadingMastery < 100 ? currentWord.ReadingMastery : currentWord.KanjiMastery < 100 ? currentWord.KanjiMastery : currentWord.TranslationMastery; this.lblIdMastery.Text = "ID:" + currentWord.Id + " " + "Lv:" + mastery; // Source this.lbSource.Text = "「" + currentSource.Text + "」より"; // Word var wordOnTop = CurrentStudyingType == StudyingType.Reading ? currentWord.Kanji : CurrentStudyingType == StudyingType.Kanji ? currentWord.Kana : "-"; this.lbWord.Text = wordOnTop; // Quote var a = currentWord.ReadingMastery; var b = currentWord.KanjiMastery; var c = currentWord.TranslationMastery; var quoteText = currentQuote.Text; if (CurrentStudyingType == StudyingType.Kanji) { quoteText = QuoteKanjiToKanas(quoteText, currentWord.Kanji, currentWord.Kana); } else if (CurrentStudyingType == StudyingType.Translation) { quoteText = QuoteKanjiToNakatens(quoteText, currentWord.Kanji, currentWord.Kana); } this.lbQuote.Text = currentQuote.Character + "「" + quoteText + "」"; // Translation / definition this.lbDefinitionOrTranslation.Text = CurrentStudyingType == StudyingType.Translation ? currentWord.Translation : ""; // Update buttons btnNext.Visible = true; btnMasteryUp.Visible = btnMasteryDown.Visible = false; // TODO better logging _logger.CloseSection(_location); }