Exemplo n.º 1
0
        public ActionResult Edit([Bind(Include = "Id,Isbn,Title,Author,Page,Publisher,PublicationYear,Available,CategoryId")] Book book)
        {
            if (ModelState.IsValid)
            {
                if (User.IsInRole("Admin") || User.IsInRole("Librarian"))
                {
                    try
                    {
                        _repo.Actualize(book);
                        _repo.SaveChanges();
                    }
                    catch
                    {
                        return(View(book));
                    }
                }
                else
                {
                    return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
                }
            }
            ViewBag.CategoryId = new SelectList(_context.Category, "Id", "Name", book.CategoryId);

            return(View(book));
        }