Example #1
0
        private void AddNote(List <MyNoteData> mynotedata)
        {
            Console.Clear();
            Console.WriteLine("Type TITLE");
            Console.Write(">");
            var title = Console.ReadLine();


            Console.WriteLine("Type Body");
            Console.Write(">");
            var body = Console.ReadLine();

            var newNote = new MyNoteData {
                BODY = body, TITLE = title
            };

            var privateNote = new MyPrivateNotes();
            var addResult   = privateNote.AddNote(mynotedata, newNote);

            Console.WriteLine(addResult.Message);
            Console.WriteLine("You want add more? (y/n)");
            Console.Write(">");
            var yesno = Console.ReadLine();

            if (Confirm(yesno))
            {
                AddNote(mynotedata);
            }
            else
            {
                this.Start(mynotedata);
            }
        }
Example #2
0
        private void EditNote(List <MyNoteData> mynotedata)
        {
            var privateNote = new MyPrivateNotes();

            Console.Clear();
            Console.WriteLine("Type ID Note for edit");
            Console.Write(">");
            var idedit = Console.ReadLine();

            var readRes = privateNote.ReadNote(mynotedata, idedit);

            if (readRes.Result)
            {
                var updNote = new MyNoteData {
                    ID = readRes.NoteData.First().ID, TITLE = "", BODY = ""
                };
                Console.WriteLine("Type new Title");
                Console.Write(">");
                var title = Console.ReadLine();
                updNote.TITLE = title;
                Console.WriteLine("Type new Body");
                Console.Write(">");
                var body = Console.ReadLine();
                updNote.BODY = body;

                var updREs = privateNote.Edit(mynotedata, updNote);
                Console.WriteLine(updREs.Message);
                Console.WriteLine("You want update more? (y/n)");
            }
            else
            {
                Console.WriteLine(readRes.Message);
                Console.WriteLine("Note not updated. You want update more? (y/n)");
            }

            Console.Write(">");
            var yesno = Console.ReadLine();

            if (Confirm(yesno))
            {
                EditNote(mynotedata);
            }
            else
            {
                Start(mynotedata);
            }
        }
Example #3
0
        public MyNoteResult Edit(List <MyNoteData> myNoteDataList, MyNoteData myNoteData)
        {
            var listResult = new MyNoteResult();

            var currNote = myNoteDataList.Where(x => x.ID == myNoteData.ID);

            if (!currNote.Any())
            {
                listResult.Message = $"Not fine note whith id: {myNoteData.ID}";;
                listResult.Result  = false;
                return(listResult);
            }

            currNote.First().TITLE = myNoteData.TITLE;
            currNote.First().BODY  = myNoteData.BODY;

            listResult.Message = $"Note is updated";;
            listResult.Result  = true;
            return(listResult);
        }
Example #4
0
        public MyNoteResult AddNote(List <MyNoteData> mynotedataList, MyNoteData myNoteData)
        {
            var addResult = new MyNoteResult();

            addResult.NoteData = mynotedataList;
            try
            {
                int id = mynotedataList.Count() + 1;
                myNoteData.ID = id;
                mynotedataList.Add(myNoteData);
                addResult.Result  = true;
                addResult.Message = "Note sucessfuly added";
            }
            catch (Exception e)
            {
                addResult.Result  = false;
                addResult.Message = $"Note not added: {e.Message}";
            }

            return(addResult);
        }