Add Exception middleware
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using AutoMapper;
|
||||
using Diary.Component.Entries.Repository;
|
||||
using Diary.Data;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@@ -18,11 +19,13 @@ namespace Diary.Component.Entries.Service
|
||||
{
|
||||
private readonly IEntryRepository _entryRepository;
|
||||
private readonly IMapper _mapper;
|
||||
private readonly IUnitOfWork _unitOfWork;
|
||||
|
||||
public EntryService(IEntryRepository entryRepository, IMapper mapper)
|
||||
public EntryService(IEntryRepository entryRepository, IMapper mapper, IUnitOfWork unitOfWork)
|
||||
{
|
||||
_entryRepository = entryRepository ?? throw new ArgumentNullException(nameof(entryRepository));
|
||||
_mapper = mapper ?? throw new ArgumentNullException(nameof(mapper));
|
||||
_unitOfWork = unitOfWork ?? throw new ArgumentNullException(nameof(unitOfWork));
|
||||
}
|
||||
|
||||
|
||||
@@ -32,6 +35,8 @@ namespace Diary.Component.Entries.Service
|
||||
|
||||
await _entryRepository.CreateAsync(entry);
|
||||
|
||||
await _unitOfWork.CompleteAsync();
|
||||
|
||||
return _mapper.Map<EntryResource>(entry);
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user