Added Entry initial repo and services for a create action.
This commit is contained in:
26
Component/Entries/Repository/EntryRepository.cs
Normal file
26
Component/Entries/Repository/EntryRepository.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using Diary.Data;
|
||||
|
||||
namespace Diary.Component.Entries.Repository
|
||||
{
|
||||
public interface IEntryRepository
|
||||
{
|
||||
Task<Entry> CreateAsync(Entry entry);
|
||||
}
|
||||
|
||||
|
||||
public class EntryRepository : IEntryRepository
|
||||
{
|
||||
private readonly IDiaryDBContext _diaryDbContext;
|
||||
|
||||
public EntryRepository(IDiaryDBContext diaryDbContext)
|
||||
{
|
||||
_diaryDbContext = diaryDbContext ?? throw new ArgumentNullException(nameof(diaryDbContext));
|
||||
}
|
||||
|
||||
public async Task<Entry> CreateAsync(Entry entry)
|
||||
{
|
||||
await _diaryDbContext.Entries.AddAsync(entry);
|
||||
return entry;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user