Пример #1
0
        /// <summary>
        /// Checking author's input and sending it to the database
        /// </summary>
        /// <returns>True if author sent to DB, otherwise false</returns>
        private bool AddItemAuthor()
        {
            AuthorAddViewModel viewmodel = (AuthorAddViewModel)DataContext;
            Author             author    = viewmodel.MyAuthor;

            if (string.IsNullOrEmpty(author.LastName))
            {
                MessageBox.Show("Last name cannnot be empty.");
                return(false);
            }
            try
            {
                int id = MSAConnectionDB.SaveAuthorToDB(author);
                author.AuthorId = id;
                Authors.AddAuthor(author);
                ActivateMainWindow();
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }
            return(true);
        }