private Deck InitializaDeck()
        {
            Deck deck = new Deck("Test Deck");

            Card card = deck.AddCard();

            card.SideA = "sideA - 你好";
            card.SideB = "sideB - 你好";
            card.Notes = "notes - 你好";
            card.Tags  = "tags";

            CardInstance sideAToB     = card.GetInstanceSideAToB();
            CardPlan     sideAToBPlan = sideAToB.Plan;

            sideAToBPlan.LastDays = 1;
            CardReview sideAToBValue = sideAToB.AddReview();

            sideAToBValue.DateTime = DateTimeOffset.Now;
            sideAToBValue.Value    = ReviewValues.Values.VALUE_1;

            CardInstance sideBToA     = card.GetInstanceSideBToA();
            CardPlan     sideBToAPlan = sideBToA.Plan;

            sideBToAPlan.LastDays = 1;
            CardReview sideBToAValue = sideBToA.AddReview();

            sideBToAValue.DateTime = DateTimeOffset.Now;
            sideBToAValue.Value    = ReviewValues.Values.VALUE_1;

            return(deck);
        }
Esempio n. 2
0
        private async Task SaveReview(int cardInstanceId)
        {
            using (var cardDao = new CardDao(DbContext))
            {
                CardInstance cardInstance = await cardDao.GetCardInstanceWithPlan(cardInstanceId);

                if (cardInstance == null)
                {
                    return;
                }

                DateTimeOffset now  = DateTimeOffset.Now;
                CardPlan       plan = cardInstance.Plan;
                if (plan.NextDate != null &&
                    now < plan.NextDate)
                {
                    return;
                }

                var    value       = int.Parse(GetParameter("value"));
                Values reviewValue = GetValueFromOrdinal(value);

                PlannerResult plannerResult = Planner.PlanNext(
                    reviewValue,
                    now,
                    plan.LastDate);

                plan.LastDate = now;
                plan.LastDays = plannerResult.PassedDays;
                plan.NextDate = plannerResult.NextDate;
                plan.NextDays = plannerResult.DaysNext;

                var review = cardInstance.AddReview();
                review.DateTime = now;
                review.Value    = reviewValue;

                await cardDao.UpdateCardInstance(cardInstance);
            }
        }