Exemplo n.º 1
0
        public ActionResult CategoryNew(Guid bookId)
        {
            Fail.IfArgumentEmpty(bookId, nameof(bookId));

            var category = BookStore.GetBookById(bookId);
            var model    = new NewCategoryModel(category);

            return(View(model));
        }
Exemplo n.º 2
0
        public ActionResult CategoryCreate([NotNull] NewCategoryModel model)
        {
            Fail.IfArgumentNull(model, nameof(model));
            Fail.IfArgumentEmpty(model.BookId, nameof(model.BookId));
            Fail.IfArgumentWhiteSpace(model.Name, nameof(model.Name));

            var book     = BookStore.GetBookById(model.BookId);
            var category = book.CreateCategory(model.Name);

            book.Save();

            return(RedirectToCategoryEditor(category));
        }