public ActionResult Create(FormCollection collection)
        {
            if (Session["User"] == null)
            {
                return(RedirectToAction("Login", "Pages"));
            }

            try
            {
                // Let's create a new author and fill it with the form's data
                BL.Author author = new BL.Author();
                author.About     = collection["About"];
                author.BirthYear = Convert.ToInt32(collection["BirthYear"]);
                author.FirstName = collection["FirstName"];
                author.LastName  = collection["LastName"];

                author.save();

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
        public ActionResult Delete(int id)
        {
            if (Session["User"] == null)
            {
                return(RedirectToAction("Login", "Pages"));
            }

            try
            {
                // First, let's get the author
                BL.Author author = BL.Author.getByAid(id);

                // Then, let's get all his/her books
                List <BL.Book> books = author.getBooks();

                // Let's delete every links between the author and his/her books
                BL.BookAuthor.delete(author.Aid);

                // Let's delete the author
                author.delete();

                foreach (var book in books)
                {
                    // If there isn't any other other attached to the book, it must be deleted
                    if (book.onlyBelongsTo(author.Aid))
                    {
                        book.delete();
                    }
                }
            }
            catch
            {
                return(View("Error500"));
            }

            return(RedirectToAction("Index"));
        }