Skip to content

Commit

Permalink
Use data model when adding a new item
Browse files Browse the repository at this point in the history
Use the data model instead of a primitive to allow further options to be developed later on.
  • Loading branch information
mehmetseckin committed Oct 15, 2019
1 parent 6fa7e49 commit 54e8663
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
6 changes: 5 additions & 1 deletion src/Todo.CLI/Handlers/AddCommandHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.IO;
using System.Reflection;
using Todo.Core;
using Todo.Core.Model;

namespace Todo.CLI.Handlers
{
Expand All @@ -14,7 +15,10 @@ public static ICommandHandler Create(IServiceProvider serviceProvider)
return CommandHandler.Create<string>(async (subject) =>
{
var todoItemRepository = (ITodoItemRepository)serviceProvider.GetService(typeof(ITodoItemRepository));
await todoItemRepository.AddAsync(subject);
await todoItemRepository.AddAsync(new TodoItem()
{
Subject = subject
});
});
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Todo.Core/Repository/ITodoItemRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace Todo.Core
{
public interface ITodoItemRepository
{
Task AddAsync(string subject);
Task AddAsync(TodoItem item);
Task<IEnumerable<TodoItem>> ListAsync(bool listAll);
}
}
4 changes: 2 additions & 2 deletions src/Todo.Core/Repository/TodoItemRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ public TodoItemRepository(IAuthenticationProvider authenticationProvider)
{
}

public async Task AddAsync(string subject)
public async Task AddAsync(TodoItem item)
{
var graphServiceClient = new GraphServiceClient(AuthenticationProvider);
await graphServiceClient.Me.Outlook.Tasks.Request().AddAsync(new OutlookTask()
{
Subject = subject
Subject = item.Subject
});
}

Expand Down

0 comments on commit 54e8663

Please sign in to comment.