예제 #1
0
        public void CreateBook(BookModel bookModel, FormCollection formCollection, Controller controller)
        {
            bookModel.BookId = Guid.NewGuid();

            Author             author   = null;
            Category           category = null;
            HttpPostedFileBase fileBook = null;
            HttpPostedFileBase fileImg  = null;

            this.FindFiles(formCollection, controller.Request.Files, ref fileBook, ref fileImg, bookModel, controller);

            this.FindAuthorAndCategory(ref author, ref category, formCollection, controller);


            if (controller.ModelState.IsValid)
            {
                Book book = BookModel.CreateBookWithoutAuthorAndCategory(bookModel);

                this.PoblateAuthorAndCategoryOfBook(book, author, category);

                this.SaveUrlBookAndUrlImg(book, fileBook, fileImg, controller);

                this.bookSetWrapper.Add(book);

                this.SaveChanges();
            }

            this.PoblateDropDownToAuthorAndCategory(bookModel, controller);
        }