public async Task <IActionResult> CreateSpellingList(SpellingListViewModel spellingListVM)
        {
            if (ModelState.IsValid)
            {
                SpellingList newSpellingList = new SpellingList()
                {
                    Name            = spellingListVM.Name,
                    Description     = spellingListVM.Description,
                    TeacherUsername = User.Identity.Name
                };

                try
                {
                    await _context.SpellingLists.AddAsync(newSpellingList);

                    await _context.SaveChangesAsync();

                    ViewData["message"] = $"You have successfully added the Spelling List named {newSpellingList.Name}";
                }
                catch (Exception ex)
                {
                    ViewData["message"] = "There was an error updating the database. Please try again.";
                }
            }
            ModelState.Clear();

            return(View());
        }
        public async Task <IActionResult> EditList(SpellingListViewModel spellingListVM)
        {
            if (ModelState.IsValid)
            {
                var spellingList = await _context.SpellingLists.SingleOrDefaultAsync(l => l.SpellingListId == spellingListVM.SpellingListId);

                spellingList.Name        = spellingListVM.Name;
                spellingList.Description = spellingListVM.Description;

                _context.SpellingLists.Update(spellingList);
                await _context.SaveChangesAsync();
            }

            return(RedirectToAction("CreateSpellingList"));
        }
        // GET: Teacher/EditList
        // Edit the chosen list
        public async Task <IActionResult> EditList(int?Id)
        {
            if (Id == null)
            {
                return(NotFound());
            }
            else
            {
                var spellingList = await _context.SpellingLists.SingleOrDefaultAsync(l => l.SpellingListId == Id);

                SpellingListViewModel spellingListVM = new SpellingListViewModel()
                {
                    SpellingListId = spellingList.SpellingListId,
                    Name           = spellingList.Name,
                    Description    = spellingList.Description
                };

                return(View(spellingListVM));
            }
        }