Ejemplo n.º 1
0
        private void AddNewAuthor()
        {
            if (Page.IsValid)
            {
                string firstName = txtFirstName.Text;
                string lastName = txtLastName.Text;
                string origin = ddlCountries.SelectedItem.Text;
                string photo = ddlPhotos.SelectedValue;
                string biography = txtBiography.Text;

                //Creates an instance of Author class
                Author author = new Author(firstName, lastName, origin, photo, biography);

                if (!author.CheckIfAuthorExists(firstName,lastName))
                {
                    //Appends a new author into database
                    author.AddAuthor(author);
                    lblNewAuthor.Text = firstName +" "+ lastName;
                    divSuccess.Visible = true;
                    divFail.Visible = false;
                    ClearTextFields();
                }
                else
                {
                    author = null;
                    divSuccess.Visible = false;
                    divFail.Visible = true;
                }
            }
        }
Ejemplo n.º 2
0
 public ActionResult IndexAuthor(AuthBookPublish model)
 {
     if (ModelState.IsValid)
     {
         authors.AddAuthor(model.author);
         AllViewBag();
         return(View("Index"));
     }
     else
     {
         AllViewBag();
         return(View("Index"));
     }
 }