public async Task <IActionResult> OnGetAsync(string BibleId, int Id) { IdentityUser user = await _userManager.GetUserAsync(User); PBEUser = await QuizUser.GetOrAddPBEUserAsync(_context, user.Email); // Static method not requiring an instance if (!PBEUser.IsQuizModerator()) { return(RedirectToPage("/error", new { errorMessage = "Sorry! You do not have sufficient rights to edit a PBE BookList" })); } BookList = await _context.QuizBookLists.FindAsync(Id); if (BookList == null) { return(RedirectToPage("/error", new { errorMessage = "That's Odd! We weren't able to find this Book List" })); } this.BibleId = await Bible.GetValidPBEBibleIdAsync(_context, BibleId); //Initialize Books await _context.Entry(BookList).Collection(L => L.QuizBookListBookMaps).LoadAsync(); BookList.PadBookListBookMapsForEdit(); Books = BookList.QuizBookListBookMaps.ToList(); Name = BookList.BookListName; ViewData["BookSelectList"] = await BibleBook.GetBookSelectListAsync(_context, BibleId); return(Page()); }
public async Task <IActionResult> OnGetAsync(int Id, string Message) { IdentityUser user = await _userManager.GetUserAsync(User); Group = await _context.GameGroups.FindAsync(Id); if (Group == null) { return(RedirectToPage("/error", new { errorMessage = "That's Odd! We weren't able to find that Group" })); } if (Group.Owner != user.Email) { return(RedirectToPage("/error", new { errorMessage = "Sorry, Only the owner can manage a Group" })); } SelectedPath = await _context.Paths.FindAsync(Group.PathId); if (SelectedPath == null) { return(RedirectToPage("/error", new { errorMessage = "That's Odd! We weren't able to find the Path for this Group" })); } _context.Entry(Group) .Collection(g => g.GameTeams) .Load(); ViewData["PathSelectList"] = await GameGroup.GetPathSelectListAsync(_context); UserMessage = GetUserMessage(Message); return(Page()); }
public async Task <IActionResult> OnGetAsync(int Id, string BibleId) { IdentityUser user = await _userManager.GetUserAsync(User); PBEUser = await QuizUser.GetOrAddPBEUserAsync(_context, user.Email); // Static method not requiring an instance Template = await _context.PredefinedQuizzes.FindAsync(Id); if (Template == null) { return(RedirectToPage("/error", new { errorMessage = "Thats Odd! We were unable to find this Quiz Template" })); } if (!PBEUser.IsValidPBEQuestionBuilder() || PBEUser != Template.QuizUser) { return(RedirectToPage("/error", new { errorMessage = "Sorry! You do not have sufficient rights to configure this Quiz Template" })); } this.BibleId = await Bible.GetValidPBEBibleIdAsync(_context, BibleId); //Initialize Our Template _context.Entry(Template).Collection(T => T.PredefinedQuizQuestions).Load(); Questions = Template.IntiQuestionListForAddEdit(); // Initialize Template Books TemplateBooks = await Template.GetTemplateBooksAsync(_context, this.BibleId); JSONBooks = JsonSerializer.Serialize(TemplateBooks); // Build Select Lists foreach (PredefinedQuizQuestion Question in Questions) { Question.AddChapterSelectList(TemplateBooks); } ViewData["BookSelectList"] = MinBook.GetMinBookSelectListFromList(TemplateBooks); return(Page()); }
public async Task <IActionResult> OnGetAsync(int QuestionId, string Caller) { ReturnPath = Caller; IdentityUser user = await _userManager.GetUserAsync(User); PBEUser = await QuizUser.GetOrAddPBEUserAsync(_context, user.Email); if (!PBEUser.IsValidPBEQuestionBuilder()) { return(RedirectToPage("/error", new { errorMessage = "Sorry! You do not have sufficient rights to edit a PBE question" })); } Question = await _context.QuizQuestions.FindAsync(QuestionId); if (Question == null) { return(RedirectToPage("/error", new { errorMessage = "That's Odd! We weren't able to find this Question" })); } // Setup our PBEBook Object Question.BibleId = await QuizQuestion.GetValidBibleIdAsync(_context, Question.BibleId); BibleBook PBEBook = await BibleBook.GetPBEBookAndChapterAsync(_context, Question.BibleId, Question.BookNumber, Question.Chapter); if (PBEBook == null) { return(RedirectToPage("/error", new { errorMessage = "That's Odd! We weren't able to find the PBE Book." })); } Question.PopulatePBEQuestionInfo(PBEBook); Question.Verses = await Question.GetBibleVersesAsync(_context, false); // We need an answer text, and while techincally we support multiple Answers // we are only going to allow operating on the first one in this basic edit experience. await _context.Entry(Question).Collection(Q => Q.QuizAnswers).LoadAsync(); if (Question.QuizAnswers.Count > 0) { AnswerText = Question.QuizAnswers.OrderBy(A => A.Id).First().Answer; } else { AnswerText = ""; } IsCommentary = (Question.Chapter == Bible.CommentaryChapter); if (IsCommentary == false) { ChapterQuestionCount = PBEBook.BibleChapters.Where(c => c.ChapterNumber == Question.Chapter).First().QuestionCount; } CommentaryQuestionCount = PBEBook.CommentaryQuestionCount; // and now we need a Verse Select List ViewData["VerseSelectList"] = new SelectList(Question.Verses, "Verse", "Verse"); ViewData["PointsSelectList"] = Question.GetPointsSelectList(); return(Page()); }