public async Task <IActionResult> Edit(int id, [Bind("ID,Question,QuestionAuthor,QuestionDate,Theme")] QOTD qOTD) { if (id != qOTD.ID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(qOTD); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!QOTDExists(qOTD.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(qOTD)); }
public async Task <IActionResult> Create([Bind("ID,Question,QuestionAuthor,QuestionDate,Theme")] QOTD qOTD) { if (ModelState.IsValid) { _context.Add(qOTD); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(qOTD)); }
public async Task <IActionResult> Create([FromRoute] int id) { // REVIEW //Take assignment of Question ID from the QOTD Index Page, User is not allowed to specify // specific page on the actua page with the form // creating select list QOTD QuestionQuery = _context.QOTD.Where(x => x.ID == id).Select(x => x).FirstOrDefault(); List <AuthorListElement> AuthorQuery = await _context.ParticipantQOTD.Select(x => new AuthorListElement { FullName = x.GivenName + " " + x.FamilyName, ID = x.ID }).OrderBy(x => x.FullName).Distinct().ToListAsync(); var QOTDAnswerVM = new QOTDAnswerCreateEditViewModel(); Add(AuthorQuery, 4); QOTDAnswerVM.Authors = Add(AuthorQuery, 4); QOTDAnswerVM.Question = QuestionQuery.Question; QOTDAnswerVM.QuestionDate = QuestionQuery.QuestionDate; QOTDAnswerVM.QuestionID = id; return(View(QOTDAnswerVM)); }