Ejemplo n.º 1
0
        public ActionResult WordNew(Guid categoryId)
        {
            Fail.IfArgumentEmpty(categoryId, nameof(categoryId));

            var category = BookStore.GetCategory(categoryId);
            var model    = new NewWordModel(category);

            return(View(model));
        }
Ejemplo n.º 2
0
        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 }));
        }