Пример #1
0
        public ActionResult AddBook(BookEditModel model)
        {
            if (ModelState.IsValid)
            {
                if (model.Book.DepartmentId == 0)
                {
                    model.Book.DepartmentId = null;
                }

                BookBs bs     = new BookBs();
                var    result = bs.Add((BookDTO)model);

                if (result.Code == BusinessLayer.OperationStatusEnum.Success)
                {
                    TempData["OperationStatus"] = true;
                    TempData["OpearionMessage"] = "Данные успешно обновлены";

                    return(RedirectToAction("Books", "Admin"));
                }
                else
                {
                    TempData["OperationStatus"] = false;
                    TempData["OpearionMessage"] = result.Message;
                }
            }

            AuthorBs authorBs = new AuthorBs();

            model.Authors = authorBs.GetList().Select(c => (AuthorModel)c).ToList();
            DepartmentBs dbs = new DepartmentBs();

            model.Departments = dbs.GetList().Where(c => c.LibraryId == model.SelectedLib).Select(c => (DepartmentModel)c).ToList();
            return(View(model));
        }
Пример #2
0
        public void AddBook(string title, string author)
        {
            BookB newbook = new BookB(title, author)
            {
                TitleB  = title,
                AuthorB = author
            };

            BookBs.Add(newbook);
        }