private void Edit()
        {
            Post postToEdit = Choose("Which post would you like to edit?");

            if (postToEdit == null)
            {
                return;
            }

            Console.WriteLine();
EditTitle:
            Console.Write("New title for the post (blank to leave unchanged): ");
            string title = Console.ReadLine();

            if (title.Length > 55)
            {
                Console.WriteLine();
                Console.WriteLine("Title was too long. Please Enter a title:");
                goto EditTitle;
            }
            else if (!string.IsNullOrWhiteSpace(title))
            {
                postToEdit.Title = title;
            }

            Console.Write("New URL for the post (blank to leave unchanged): ");
EditUrl:
            string url = Console.ReadLine();

            if (url.Length > 2000)
            {
                Console.WriteLine();
                Console.WriteLine("Url was too long. Please Enter a url:");
                goto EditUrl;
            }
            else if (!string.IsNullOrWhiteSpace(url))
            {
                postToEdit.Url = url;
            }

            Console.Write("New publishing date for the post (blank to leave unchanged): ");
            string datePublished = Console.ReadLine();

            if (!string.IsNullOrWhiteSpace(datePublished))
            {
                postToEdit.PublishDateTime = Convert.ToDateTime(datePublished);;
            }


            AuthorManager authorManager = new AuthorManager(this, _connectionString);

            postToEdit.Author = authorManager.ChooseAuthor();

            BlogManager blogManager = new BlogManager(this, _connectionString);

            postToEdit.Blog = blogManager.ChooseBlog();

            _postRepository.Update(postToEdit);
        }
 // Define a PostManager Constructor method to build an instance of the PostManager Type
 public PostManager(IUserInterfaceManager parentUI, string connectionString)
 {
     _parentUI         = parentUI;
     _postRepository   = new PostRepository(connectionString);
     _authorManager    = new AuthorManager(parentUI, connectionString);
     _blogManager      = new BlogManager(parentUI, connectionString);
     _connectionString = connectionString;
 }
        private void Edit()
        {
            Post postToEdit = Choose("Which post would you like to edit?");

            if (postToEdit == null)
            {
                return;
            }

            Console.WriteLine();
            Console.Write("New title (blank to leave unchanged: ");
            string title = Console.ReadLine();

            if (!string.IsNullOrWhiteSpace(title))
            {
                postToEdit.Title = title;
            }
            Console.Write("New URL (blank to leave unchanged: ");
            string url = Console.ReadLine();

            if (!string.IsNullOrWhiteSpace(url))
            {
                postToEdit.Url = url;
            }
            AuthorManager    authorManager = new AuthorManager(this, _connectionString);
            AuthorRepository authRepo      = new AuthorRepository(_connectionString);

            Author newAuthor = authorManager.Choose();

            if (newAuthor != null)
            {
                postToEdit.Author = newAuthor;
            }
            else
            {
                postToEdit.Author = authRepo.Get(postToEdit.Author.Id);
            }
            BlogManager    blogManager = new BlogManager(this, _connectionString);
            BlogRepository blogRepo    = new BlogRepository(_connectionString);

            Blog newBlog = blogManager.Choose();

            if (newBlog != null)
            {
                postToEdit.Blog = newBlog;
            }
            else
            {
                postToEdit.Blog = blogRepo.Get(postToEdit.Blog.Id);
            }

            _postRepository.Update(postToEdit);
        }
        private void Add()
        {
            AuthorRepository authRepo = new AuthorRepository(_connectionString);

            Console.WriteLine("New Post");
            Post post = new Post();

            Console.Write("Title: ");
            post.Title = Console.ReadLine();

            Console.Write("URL: ");
            post.Url = Console.ReadLine();

            Console.Write("Publish Date: ");
            post.PublishDateTime = DateTime.Parse(Console.ReadLine());

            AuthorManager authorManager = new AuthorManager(this, _connectionString);

            post.Author = authorManager.Choose();
            BlogManager blogManager = new BlogManager(this, _connectionString);

            post.Blog = blogManager.Choose();
            _postRepository.Insert(post);
        }
        private void Add()
        {
            Console.WriteLine("New Post");
            Post post = new Post();

            Console.Write("Title: ");
Title:
            string title = Console.ReadLine();

            if (string.IsNullOrWhiteSpace(title))
            {
                Console.WriteLine();
                Console.WriteLine("Please Enter a title:");
                goto Title;
            }

            else if (title.Length > 55)
            {
                Console.WriteLine();
                Console.WriteLine("Title was too long. Please Enter a title:");
                goto Title;
            }
            post.Title = title;

            Console.Write("URL: ");
Url:
            string url = Console.ReadLine();

            if (string.IsNullOrWhiteSpace(url))
            {
                Console.WriteLine();
                Console.WriteLine("Please Enter a url:");
                goto Url;
            }
            else if (url.Length > 2000)
            {
                Console.WriteLine();
                Console.WriteLine("Url was too long. Please Enter a url:");
                goto Url;
            }
            post.Url = url;

            bool badDate = true;

            while (badDate)
            {
                try
                {
                    Console.Write("Date published: ");
                    post.PublishDateTime = Convert.ToDateTime(Console.ReadLine());
                    badDate = false;
                }
                catch (Exception)
                {
                    Console.WriteLine("Date not accepted, please try again");
                }
            }



            AuthorManager authorManager = new AuthorManager(this, _connectionString);

            post.Author = authorManager.ChooseAuthor();

            BlogManager blogManager = new BlogManager(this, _connectionString);

            post.Blog = blogManager.ChooseBlog();

            _postRepository.Insert(post);
        }