Add entries controller
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
using Microsoft.AspNetCore.Mvc;
|
using Diary.Component.Entries.Service;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@@ -11,9 +12,20 @@ namespace Diary.Component.Entries
|
|||||||
[Route("[controller]")]
|
[Route("[controller]")]
|
||||||
public class EntriesController:ControllerBase
|
public class EntriesController:ControllerBase
|
||||||
{
|
{
|
||||||
public EntriesController()
|
private readonly IEntryService _entryService;
|
||||||
{
|
|
||||||
|
|
||||||
|
public EntriesController(IEntryService entryService)
|
||||||
|
{
|
||||||
|
_entryService = entryService ?? throw new ArgumentNullException(nameof(entryService));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public async Task<EntryResource> CreateEntryAsync(CreateEntryResource create)
|
||||||
|
{
|
||||||
|
return await _entryService.CreateAsync(create);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
17
Data/UnitOfWork.cs
Normal file
17
Data/UnitOfWork.cs
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Diary.Data
|
||||||
|
{
|
||||||
|
public class UnitOfWork
|
||||||
|
{
|
||||||
|
public UnitOfWork()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,6 @@
|
|||||||
using System;
|
using Diary.Component.Entries.Repository;
|
||||||
|
using Diary.Component.Entries.Service;
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
@@ -10,6 +12,11 @@ namespace Diary.Installers
|
|||||||
{
|
{
|
||||||
public static IServiceCollection AddDependencies(this IServiceCollection services)
|
public static IServiceCollection AddDependencies(this IServiceCollection services)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
services.AddScoped<IEntryService, EntryService>();
|
||||||
|
services.AddScoped<IEntryRepository, EntryRepository>();
|
||||||
|
|
||||||
return services;
|
return services;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,6 +44,11 @@ try
|
|||||||
builder.Services.AddDatabase(builder.Configuration);
|
builder.Services.AddDatabase(builder.Configuration);
|
||||||
builder.Services.AddScoped<IDiaryDBContext, DiaryDBContext>();
|
builder.Services.AddScoped<IDiaryDBContext, DiaryDBContext>();
|
||||||
|
|
||||||
|
//---y
|
||||||
|
//Dependancies
|
||||||
|
builder.Services.AddDependencies();
|
||||||
|
|
||||||
|
|
||||||
//---Y
|
//---Y
|
||||||
//Automapper
|
//Automapper
|
||||||
builder.Services.AddAutoMapper(Assembly.GetExecutingAssembly());
|
builder.Services.AddAutoMapper(Assembly.GetExecutingAssembly());
|
||||||
|
|||||||
Reference in New Issue
Block a user