Refactored ICRUDService interface to remove the generic TCRUDRepository parameter for simplification and improved readability.
This commit is contained in:
@@ -6,9 +6,8 @@ namespace DigitalData.Core.API
|
||||
{
|
||||
[ApiController]
|
||||
[Route("api/[controller]")]
|
||||
public class BasicCRUDControllerBase<TCRUDService, TCRUDRepository, TDto, TEntity, TId> : CRUDControllerBase<TCRUDService, TCRUDRepository, TDto, TDto, TDto, TEntity, TId>
|
||||
where TCRUDService : ICRUDService<TCRUDRepository, TDto, TDto, TDto, TEntity, TId>
|
||||
where TCRUDRepository : ICRUDRepository<TEntity, TId>
|
||||
public class BasicCRUDControllerBase<TCRUDService, TDto, TEntity, TId> : CRUDControllerBase<TCRUDService, TDto, TDto, TDto, TEntity, TId>
|
||||
where TCRUDService : ICRUDService<TDto, TDto, TDto, TEntity, TId>
|
||||
where TDto : class
|
||||
where TEntity : class
|
||||
{
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using DigitalData.Core.Contracts.Application;
|
||||
using DigitalData.Core.Contracts.Infrastructure;
|
||||
using DigitalData.Core.DTO;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
@@ -16,9 +15,8 @@ namespace DigitalData.Core.API
|
||||
/// <typeparam name="TId">The type of the entity's identifier.</typeparam>
|
||||
[ApiController]
|
||||
[Route("api/[controller]")]
|
||||
public class CRUDControllerBase<TCRUDService, TCRUDRepository, TCreateDto, TReadDto, TUpdateDto, TEntity, TId> : ControllerBase
|
||||
where TCRUDService : ICRUDService<TCRUDRepository, TCreateDto, TReadDto, TUpdateDto, TEntity, TId>
|
||||
where TCRUDRepository : ICRUDRepository<TEntity, TId>
|
||||
public class CRUDControllerBase<TCRUDService, TCreateDto, TReadDto, TUpdateDto, TEntity, TId> : ControllerBase
|
||||
where TCRUDService : ICRUDService<TCreateDto, TReadDto, TUpdateDto, TEntity, TId>
|
||||
where TCreateDto : class
|
||||
where TReadDto : class
|
||||
where TUpdateDto : class
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using DigitalData.Core.Contracts.Application;
|
||||
using DigitalData.Core.Contracts.Infrastructure;
|
||||
using DigitalData.Core.DTO;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace DigitalData.Core.API
|
||||
@@ -12,9 +12,8 @@ namespace DigitalData.Core.API
|
||||
/// <typeparam name="TId">The type of the entity's identifier.</typeparam>
|
||||
[ApiController]
|
||||
[Route("api/[controller]")]
|
||||
public class ReadControllerBase<TBasicCRUDService, TCRUDRepository, TReadDto, TEntity, TId> : ControllerBase
|
||||
where TBasicCRUDService : IBasicCRUDService<TCRUDRepository, TReadDto, TEntity, TId>
|
||||
where TCRUDRepository : ICRUDRepository<TEntity, TId>
|
||||
public class ReadControllerBase<TBasicCRUDService, TReadDto, TEntity, TId> : ControllerBase
|
||||
where TBasicCRUDService : IBasicCRUDService<TReadDto, TEntity, TId>
|
||||
where TReadDto : class
|
||||
where TEntity : class
|
||||
{
|
||||
@@ -42,12 +41,13 @@ namespace DigitalData.Core.API
|
||||
[HttpGet("{id}")]
|
||||
public virtual async Task<IActionResult> GetById([FromRoute] TId id)
|
||||
{
|
||||
var result = await _service.ReadByIdAsync(id);
|
||||
if (result.IsSuccess)
|
||||
{
|
||||
return Ok(result);
|
||||
}
|
||||
return NotFound(result);
|
||||
return await _service.ReadByIdAsync(id).ThenAsync(
|
||||
Success: Ok,
|
||||
Fail: IActionResult (messages, notices) =>
|
||||
{
|
||||
_logger.LogNotice(notices);
|
||||
return NotFound(messages);
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -57,12 +57,13 @@ namespace DigitalData.Core.API
|
||||
[HttpGet]
|
||||
public virtual async Task<IActionResult> GetAll()
|
||||
{
|
||||
var result = await _service.ReadAllAsync();
|
||||
if (result.IsSuccess)
|
||||
{
|
||||
return Ok(result);
|
||||
}
|
||||
return NotFound(result);
|
||||
return await _service.ReadAllAsync().ThenAsync(
|
||||
Success: Ok,
|
||||
Fail: IActionResult (messages, notices) =>
|
||||
{
|
||||
_logger.LogNotice(notices);
|
||||
return NotFound(messages);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user