Esempio n. 1
0
        /// <summary>
        /// Method to delete a note
        /// </summary>
        public static void DeleteNote()
        {
            Console.WriteLine("\nEnter the id of the note that you wish to delete:");
            int noteId = Convert.ToInt32(Console.ReadLine());

            if (NotesTableOperations.DeleteNote(noteId))
            {
                Console.WriteLine($"The note '{noteId}' was successfuly deleted");
            }
            else
            {
                Console.WriteLine("Operation failed!!!");
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Method to update a note
        /// </summary>
        public static void UpdateNote()
        {
            Note note = new Note();

            Console.WriteLine("\nEnter the id of the note that is to be updated:");
            note.NoteId = Convert.ToInt32(Console.ReadLine());
            Console.Write("Enter new titile: ");
            note.Title = Console.ReadLine();
            Console.Write("Enter new description: ");
            note.Description = Console.ReadLine();
            Console.Write("Select new status(1. Pending, 2. Completed, 3. Ignore)");
            int opt = Convert.ToInt32(Console.ReadLine());

            switch (opt)
            {
            case 1:
                note.Status = StatusType.Pending.ToString();
                break;

            case 2:
                note.Status = StatusType.Completed.ToString();
                break;

            case 3:
                note.Status = StatusType.Ignore.ToString();
                break;

            default:
                Console.WriteLine("Incorrect status. aborting!!!");
                return;
            }
            Console.Write("Enter new category Id: ");
            note.CategoryId = Convert.ToInt32(Console.ReadLine());
            if (NotesTableOperations.UpdateNote(note, 0))
            {
                Console.WriteLine($"Note '{note.NoteId}' update successful");
            }
            else
            {
                Console.WriteLine("Operation failed!!!");
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Method to read all properties of a note
        /// </summary>
        private static void ReadANoteProperties()
        {
            Console.WriteLine("\nEnter the note Id");
            int  noteId = Convert.ToInt32(Console.ReadLine());
            Note note   = NotesTableOperations.ReadANotesAllProperties(noteId);

            if (note != null)
            {
                Console.WriteLine("******************************");
                Console.WriteLine("Title: " + note.Title);
                Console.WriteLine("Description: " + note.Description);
                Console.WriteLine("Status: " + note.Status);
                Console.WriteLine("CategoryId: " + note.CategoryId);
                Console.WriteLine("******************************");
            }
            else
            {
                Console.WriteLine("Some error occurred!!!");
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Method to creat note
        /// </summary>
        private static void CreateNewNote()
        {
            Note note = new Note();

            Console.WriteLine("Enter new note details:\n");
            Console.Write("Title: ");
            note.Title = Console.ReadLine();
            Console.Write("Description: ");
            note.Description = Console.ReadLine();
            Console.Write("CategoryId: ");
            note.CategoryId = Convert.ToInt32(Console.ReadLine());
            if (NotesTableOperations.CreateNote(note))
            {
                Console.WriteLine("\n\n Note creation successful");
            }
            else
            {
                Console.WriteLine("\n\n Some error occurred!!!");
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Method to read all notes from table
        /// </summary>
        public static void ReadAllNotes()
        {
            List <Note> notes = NotesTableOperations.ReadAllNotes();

            if (notes.Any())
            {
                foreach (Note note in notes)
                {
                    Console.WriteLine("******************************");
                    Console.WriteLine("NoteId: " + note.NoteId);
                    Console.WriteLine("Title: " + note.Title);
                    Console.WriteLine("Description: " + note.Description);
                    Console.WriteLine("Status: " + note.Status);
                    Console.WriteLine("CategoryId: " + note.CategoryId);
                    Console.WriteLine("******************************");
                }
            }
            else
            {
                Console.WriteLine("No notes found!!!");
            }
        }