Exemple #1
0
        private void Edit()
        {
            Journal journalToEdit = Choose("which journal entry would you like to edit?");

            if (journalToEdit == null)
            {
                return;
            }

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

            if (!string.IsNullOrWhiteSpace(title))
            {
                journalToEdit.Title = title;
            }
            Console.WriteLine("New content(blank to leave unchanged: ");
            string content = Console.ReadLine();

            if (!string.IsNullOrWhiteSpace(content))
            {
                journalToEdit.Content = content;
            }
            journalToEdit.CreateDateTime = journalToEdit.CreateDateTime;

            _journalRepository.Update(journalToEdit);
        }
        private void Edit()
        {
            //    throw new NotImplementedException();
            //}
            Journal entryToEdit = Choose("Which entry would you like to edit?");

            if (entryToEdit == null)
            {
                return;
            }

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

            if (!string.IsNullOrWhiteSpace(title))
            {
                entryToEdit.Title = title;
            }
            Console.Write($"Edit content (blank to leave unchanged): {entryToEdit.Content} ");
            string content = Console.ReadLine();

            if (!string.IsNullOrWhiteSpace(content))
            {
                entryToEdit.Content = content;
            }
            //Console.Write("New bio (blank to leave unchanged: ");
            //string bio = Console.ReadLine();
            //if (!string.IsNullOrWhiteSpace(bio))
            //{
            //    entryToEdit.Bio = bio;
            //}

            _journalRepository.Update(entryToEdit);
        }
Exemple #3
0
        private void Edit()
        {
            Journal journalToEdit = Choose("Which journal entry would you like to edit?");

            if (journalToEdit == null)
            {
                return;
            }

            Console.WriteLine();
            Console.Write("Here is the current entry: ");
            {
                Console.WriteLine($"{journalToEdit.Content}");
            }
            Console.WriteLine("Press Enter to escape without editing or change your content now");



            string content = Console.ReadLine();

            if (!string.IsNullOrWhiteSpace(content))
            {
                journalToEdit.Content = content;
            }

            _journalRepository.Update(journalToEdit);
        }
        private void Edit()
        {
            Journal entryToEdit = Choose("Which journal entry would you like to edit?");

            if (entryToEdit == null)
            {
                return;
            }

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

            if (!string.IsNullOrWhiteSpace(Title))
            {
                entryToEdit.Title = Title;
            }
            Console.Write("New entry content (blank to leave unchanged: ");
            string content = Console.ReadLine();

            if (!string.IsNullOrWhiteSpace(content))
            {
                entryToEdit.Content = content;
            }

            _journalRepository.Update(entryToEdit);
        }
        /// <summary>
        ///     Ticket Edit Journal Entry #6
        ///         Edit method invokes Choose method for user to select a post,
        ///         once selected the user is prompted to update title and content,
        ///         and notified that a blank value will return the same name.
        ///
        ///         Edit method **does not** allow user to modify date created.
        /// </summary>
        private void Edit()
        {
            Journal entryToEdit = Choose("Select a journal entry to edit: ");

            if (entryToEdit == null)
            {
                return;
            }

            Console.WriteLine();
            Console.WriteLine("**Leave field blank to keep previous title**");
            Console.Write("New Entry Title: ");
            string title = Console.ReadLine();

            if (!string.IsNullOrWhiteSpace(title))
            {
                entryToEdit.Title = title;
            }
            Console.WriteLine("**Leave field blank to keep previous entry content**");
            Console.Write("New Entry Content: ");
            string content = Console.ReadLine();

            if (!string.IsNullOrWhiteSpace(content))
            {
                entryToEdit.Content = content;
            }

            _journalRepository.Update(entryToEdit);
        }
Exemple #6
0
        private void Edit()
        {
            Journal journalToEdit = Choose("Which journal would you like to edit?");

            if (journalToEdit == null)
            {
                return;
            }

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

            while (title.Length > 55)
            {
                Console.WriteLine("***Your Title cannot exceed 55 characters. Please try again.***");
                Console.Write("New Title (blank to leave unchanged): ");
                title = Console.ReadLine();
            }

            if (!string.IsNullOrWhiteSpace(title))
            {
                journalToEdit.Title = title;
            }
            Console.Write("New Content (blank to leave unchanged): ");
            string content = Console.ReadLine();

            if (!string.IsNullOrWhiteSpace(content))
            {
                journalToEdit.Content = content;
            }

            _journalRepository.Update(journalToEdit);
        }
Exemple #7
0
        private void Edit()
        {
            Journal entrySelected = Choose("What entry do you want to edit?");

            if (entrySelected == null)
            {
                return;
            }
            Console.WriteLine();
            Console.WriteLine("What's the new title?");
            string title = Console.ReadLine();

            Console.WriteLine();
            //IsNullOrWhiteSpace will check if the string is null, empty or is only spaces
            if (!string.IsNullOrWhiteSpace(title))
            {
                entrySelected.Title = title;
            }
            Console.WriteLine("Edit the content of your entry: ");
            string content = Console.ReadLine();

            if (!string.IsNullOrWhiteSpace(content))
            {
                entrySelected.Content = content;
            }
            //save to repo
            _journalRepository.Update(entrySelected);
        }
        private void Edit()
        {
            Journal journalToEdit = Choose("Which entry would you like to edit?");

            if (journalToEdit == null)
            {
                return;
            }

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

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

            if (!string.IsNullOrWhiteSpace(content))
            {
                journalToEdit.Content = content;
            }

            Console.Write("New date (blank to leave unchanged: ");
            bool success = DateTime.TryParse(Console.ReadLine(), out DateTime date);

            if (success)
            {
                journalToEdit.CreateDateTime = date;
            }

            _journalRepository.Update(journalToEdit);
        }
        //Editing a journal entry.
        private void Edit()
        {
            Journal journalToEdit = Choose("Which journal entry would you like to edit?");

            if (journalToEdit == null)
            {
                return;
            }

            //if user doesn't leave blank or unchanged then the data the user entered will be stored in title and passed into database
            Console.WriteLine();
            Console.WriteLine("New Title (blank to leave unchanged: ");
            string title = Console.ReadLine();

            if (!string.IsNullOrWhiteSpace(title))
            {
                journalToEdit.Title = title;
            }
            Console.WriteLine("Update Content (blank to leave unchanged: ");
            string content = Console.ReadLine();

            if (!string.IsNullOrWhiteSpace(content))
            {
                journalToEdit.Content = content;
            }
            Console.WriteLine("Your journal entry time will be updated to the current time.");


            journalToEdit.CreateDateTime = DateTime.Now;


            _journalRepository.Update(journalToEdit);
        }
Exemple #10
0
        //Editing A Single Journal Entry
        private void Update()
        {
            Journal journalToEdit = Choose("Which Journal Entry would you like to edit?");

            if (journalToEdit == null)
            {
                return;
            }

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

            //Catch for user entering a title that exceeds the varchar limit set inside the database
            if (Title.Length > 55)
            {
                Console.WriteLine();
                Console.WriteLine("The title you entered is too long. Please try something shorter.");
                Console.WriteLine();
                goto TitleEdit;
            }
            else if (!string.IsNullOrWhiteSpace(Title))
            {
                journalToEdit.Title = Title;
            }

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

            if (!string.IsNullOrWhiteSpace(Content))
            {
                journalToEdit.Content = Content;
            }


            _journalRepository.Update(journalToEdit);
        }
        private void Edit()
        {
            Journal entryToEdit = Choose("Which journal entry would you like to edit?");

            if (entryToEdit == null)
            {
                return;
            }

            Console.WriteLine();
            while (true)
            {
                Console.Write("New entry Title(blank to leave unchanged: ");
                string title = Console.ReadLine();
                if (title.Length > 55)
                {
                    Console.WriteLine("Journal entry titles must be less than 55 characters.");
                }
                else
                {
                    if (!string.IsNullOrWhiteSpace(title))
                    {
                        entryToEdit.Title = title;
                    }
                    break;
                }
            }
            Console.Write("New content (blank to leave unchanged: ");
            string content = Console.ReadLine();

            if (!string.IsNullOrWhiteSpace(content))
            {
                entryToEdit.Content = content;
            }

            _journalRepository.Update(entryToEdit);
        }
Exemple #12
0
        private void Edit()
        {
            // 1. loop list of jornals
            // 2. display all journals from index
            // 2.5 take input from user
            // 3. choose  from #
            // 4. check = int
            // 5. get journal that matches chosen journal
            // 6. update empty Journal bucket = chosenJournal
            // 7. Call Update(updatedJournal)
            //
            // Later... Empty or Return does NOT change existing Journal Entry.
            // Also do this on Edit Post

            // Empty bucket
            Journal journal = new Journal();

            List <Journal> journalEntries = journalRepo.GetAll();

            Console.WriteLine("\nJOURNAL ENTRIES - EDIT:");
            for (int i = 0; i < journalEntries.Count; i++)
            {
                Console.WriteLine($"\nEntry {i + 1} \n{journalEntries[i].Title} \n" +
                                  $"Date: {journalEntries[i].CreateDateTime} \n" +
                                  $"Content: {journalEntries[i].Content} ");
            }

            Console.Write("\nSelect Journal entry to edit > ");
            int  userChoice   = -1;
            bool isUserChoice = int.TryParse(Console.ReadLine(), out userChoice);

            if (isUserChoice)
            {
                journalEntries[userChoice - 1].Id = userChoice;

                Console.Write("\nEnter Journal Title > ");
                string userTitleChoice = Console.ReadLine();
                if (!string.IsNullOrWhiteSpace(userTitleChoice))
                {
                    journalEntries[userChoice - 1].Title = userTitleChoice;

                    Console.Write("\nEnter Journal Content > ");
                    string userContentChoice = Console.ReadLine();
                    if (!string.IsNullOrWhiteSpace(userContentChoice))
                    {
                        journalEntries[userChoice - 1].Content = userContentChoice;

                        Console.Write("\nEnter Date & Time > ");
                        DateTime userCreateDateTimeChoice = Convert.ToDateTime(Console.ReadLine());

                        if (userCreateDateTimeChoice != null)
                        {
                            journalEntries[userChoice - 1].CreateDateTime = userCreateDateTimeChoice;
                            //
                            journal.Id             = journalEntries[userChoice - 1].Id;
                            journal.Title          = journalEntries[userChoice - 1].Title;
                            journal.Content        = journalEntries[userChoice - 1].Content;
                            journal.CreateDateTime = journalEntries[userChoice - 1].CreateDateTime;
                            //
                            journalRepo.Update(journal);
                        }
                        else
                        {
                            Console.WriteLine("Incorrect Date & Time entered.");
                        }
                    }

                    else
                    {
                        Console.WriteLine("Incorrect Content.");
                    }
                }

                else
                {
                    Console.WriteLine("Must be greater than Zero");
                }
            }
        }