public ActionResult WordNew(Guid categoryId) { Fail.IfArgumentEmpty(categoryId, nameof(categoryId)); var category = BookStore.GetCategory(categoryId); var model = new NewWordModel(category); return(View(model)); }
public ActionResult WordCreate([NotNull] NewWordModel model) { Fail.IfArgumentNull(model, nameof(model)); Fail.IfArgumentEmpty(model.CategoryId, nameof(model.CategoryId)); var category = BookStore.GetCategory(model.CategoryId); var book = category.Book; var word = new Word(category, model.Polish, model.GetEnglishPhrases().ToList()); category.Words.Add(word); book.Save(); //var modelNew = new NewWordModel(category); //return View("WordNew", modelNew); return(RedirectToAction(nameof(WordNew), new { categoryId = category.Id })); }