/// <summary> /// Retrieves user profile data from DynamoDB 'user-profile' /// </summary> public async Task GetUserProfileData() { DatabaseItem items = await GetEntryByKey(this.UserID); if (items.TryGetValue(SCHEDULE_KEY, out AttributeValue dbSchedule)) { if (items.TryGetValue(TEACH_MODE_KEY, out AttributeValue tM)) { this.teachMode = (MODE)Enum.Parse(typeof(MODE), tM.S); } else { this.teachMode = MODE.Assess; } this.Schedule = int.Parse(dbSchedule.N); await this.scopeAndSequenceDB.GetSessionDataWithNumber(this.Schedule); log.INFO("UserProfileDB", "GetUserSchedule", "User profile exist, start the user at: " + this.Schedule); } else { await CreateNewUser(); log.INFO("UserProfileDB", "GetUserSchedule", "User profile does not exist, start the user at: " + this.Schedule); } this.lesson = LessonFactory.GetLesson(this.scopeAndSequenceDB.Lesson); }
/// <summary> /// Uses order (primary key) to retrieve the words to read and lesson type from scope and sequence Database. /// </summary> /// @param orderNumber - Integer number used as primary key for geting list of words from database. </param> public async Task GetSessionDataWithNumber(int orderNumber) { log.INFO("ScopeAndSequenceDB", "GetSessionDataWithNumber", "Order number: " + orderNumber); DatabaseItem item = await GetEntryByKey(orderNumber); if (item.TryGetValue("WordsToRead", out AttributeValue words)) { this.WordsToRead = words.SS; } if (item.TryGetValue("Mode", out AttributeValue Mode)) { this.TeachMode = Mode.S; } if (item.TryGetValue("Skill", out AttributeValue Skill)) { this.Skill = Skill.S; } if (item.TryGetValue("InSkillPurchase", out AttributeValue inSkillPurchase)) { this.ProductName = inSkillPurchase.S; } // Determine lesson plan if (item.TryGetValue("Lesson", out AttributeValue lessonType)) { this.Lesson = lessonType.S; } log.INFO("ScopeAndSequenceDB", "GetSessionDataWithNumber", "Lesson: " + this.Lesson.ToString()); }