Пример #1
0
        private void SeedHistory(PieceRandomiser pieceRandomiser)
        {
            var items = this.GetItemsAsync().Result.ToArray();

            for (var i = 0; i < items.Count(); i++)
            {
                _ = this.DeleteItemAsync(i);
            }

            for (var historyPeriodIndex = 0; historyPeriodIndex < 3; historyPeriodIndex++)
            {
                var historyStartDate = new DateTime(2020, 1, 20).AddDays(84 * historyPeriodIndex);
                _ = this.AddItemAsync(
                    new PracticeItem
                {
                    CycleStartDate             = historyStartDate,
                    SerializedRecord           = new string('1', 84),
                    SerializedPracticeSchedule = string.Join(",", pieceRandomiser.TakeRandom(12))
                }).Result;
            }

            var startDate = new DateTime(2020, 9, 28);

            _ = this.AddItemAsync(
                new PracticeItem
            {
                CycleStartDate             = startDate,
                SerializedRecord           = new string('0', 84),
                SerializedPracticeSchedule = string.Join(",", pieceRandomiser.TakeRandom(12))
            }).Result;
        }
Пример #2
0
        private static PracticeItem CreateNewItem(DateTime periodStartDate)
        {
            var pieceRandomiser  = new PieceRandomiser();
            var practiceSchedule = pieceRandomiser.TakeRandom(12).Select(piece => piece.Title);

            return(new PracticeItem
            {
                CycleStartDate = periodStartDate,
                SerializedRecord = new string('0', PeriodLengthDays),
                SerializedPracticeSchedule = string.Join(",", practiceSchedule)
            });
        }