Skip to content

Commit

Permalink
Use data model when adding a new item (#4)
Browse files Browse the repository at this point in the history
Use data model when adding a new item
  • Loading branch information
mehmetseckin authored Oct 15, 2019
2 parents 6fa7e49 + 54e8663 commit 9abeb9e
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 9abeb9e

Please sign in to comment.