-
Notifications
You must be signed in to change notification settings - Fork 1
Update todo/24 update todo #25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 11 commits
c872dfb
5d7c6db
9f9589c
b75304d
2f07ce3
3d338b9
876b1fe
d851887
88d0cac
479f610
0f1c464
9cf2a9a
936a3c2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,6 +7,7 @@ public enum TODOMENU | |
| View, | ||
| MarkAsDone, | ||
| ListAll, | ||
| Update, | ||
| Quit | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| namespace EasyList | ||
| { | ||
| public enum TodoUpdate | ||
| { | ||
| Label, | ||
| Description, | ||
| Priority, | ||
| DueDate | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,12 @@ | ||
| namespace EasyList | ||
| using EasyList.Factories; | ||
| using EasyList.Interfaces; | ||
|
|
||
| namespace EasyList | ||
| { | ||
| class Program | ||
| { | ||
| public static ITodoService _todoService = Factory.CreateTodoServiceDB(); | ||
|
||
|
|
||
| public static void Main(string[] args) | ||
| { | ||
| if(args.Length > 1) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,6 +4,7 @@ | |
| using EasyList.Enums; | ||
| using EasyList.Factories; | ||
| using EasyList.Interfaces; | ||
| using Sharprompt; | ||
|
|
||
| namespace EasyList | ||
| { | ||
|
|
@@ -50,6 +51,59 @@ public void DisplayAllTodo(TodoOrder todoOrder) | |
| .Write(Format.MarkDown); | ||
| } | ||
|
|
||
|
|
||
| public void UpdateTodo(Todo todo, TodoUpdate command) | ||
| { | ||
| switch (command) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If statement would be better here too. |
||
| { | ||
| case TodoUpdate.Label: | ||
| { | ||
| Console.WriteLine("Enter the New Label: "); | ||
| string? newLabel = Console.ReadLine(); | ||
| if (Validate.Label(newLabel)) | ||
| { | ||
| if (!Validate.TodoErrors()) | ||
| { | ||
| todo.Label = newLabel!; | ||
| } | ||
| } | ||
| _todoRepository.UpdateTodo(todo); | ||
| break; | ||
| } | ||
|
|
||
| case TodoUpdate.Description: | ||
| { | ||
| Console.WriteLine("Enter the New Description: "); | ||
| string? newDescription = Console.ReadLine(); | ||
| if (!string.IsNullOrWhiteSpace(newDescription)) | ||
| { | ||
| todo.Description = newDescription; | ||
| } | ||
| _todoRepository.UpdateTodo(todo); | ||
| break; | ||
| } | ||
|
|
||
| case TodoUpdate.Priority: | ||
| { | ||
| todo.Priority = Prompt.Select<TodoPriority>("Select new Priority."); ; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. service should not interact with the user, thats a job for the menu |
||
| _todoRepository.UpdateTodo(todo); | ||
| break; | ||
| } | ||
|
|
||
| case TodoUpdate.DueDate: | ||
| { | ||
| Console.WriteLine("Enter the New Due Date: "); | ||
| string? newDueDate = Console.ReadLine(); | ||
| if(Validate.DueDate(newDueDate)) | ||
| { | ||
| if (!Validate.TodoErrors()) | ||
| { | ||
| todo.DueDate = DateTimeOffset.Parse(newDueDate!); | ||
| } | ||
| } | ||
| _todoRepository.UpdateTodo(todo); | ||
| break; | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| using System; | ||
| using System.Collections.Generic; | ||
|
|
||
| public static class Utility | ||
| { | ||
| public static IEnumerable<int> ToIntIds(this string[] input) | ||
| { | ||
| foreach (var item in input) | ||
| { | ||
| if (int.TryParse(item, out int num)) | ||
| { | ||
| yield return num; | ||
| } | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How did this get committed? Was the code not debugged?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, Maybe Expecting only a silly string change I didn't check after this commit.