public ActionResult Create(CreateWordListViewModel model) { try { var newList = new WordList(); newList.Name = model.Name; var words = model.CommaSeparatedList .Replace(" ", string.Empty) .Split(',', StringSplitOptions.RemoveEmptyEntries); foreach (var word in words) { newList.Add(new Word() { Value = word }); } _writer.Save(newList); return(RedirectToAction(nameof(Index))); } catch { return(View()); } }
// GET: List/Create public ActionResult Create() { var model = new CreateWordListViewModel(); return(View(model)); }