Add time record API endpoint and supporting infrastructure
Introduced a new TimeController with a POST endpoint to insert and retrieve the latest time record. Added ITimeRepository, TimeRepository, and TimeRecord entity. Implemented MediatR command and handler for time insertion. Updated ApplicationDbContext and DI configuration to support the new feature.
This commit is contained in:
28
DbFirst.API/Controllers/TimeController.cs
Normal file
28
DbFirst.API/Controllers/TimeController.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using DbFirst.Application.Time.Commands;
|
||||
using DbFirst.Domain.Entities;
|
||||
using MediatR;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace DbFirst.API.Controllers;
|
||||
|
||||
[ApiController]
|
||||
[Route("api/[controller]")]
|
||||
public class TimeController : ControllerBase
|
||||
{
|
||||
private readonly IMediator _mediator;
|
||||
|
||||
public TimeController(IMediator mediator)
|
||||
{
|
||||
_mediator = mediator;
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<ActionResult<TimeRecord>> InsertAndGetLast(CancellationToken cancellationToken)
|
||||
{
|
||||
var result = await _mediator.Send(new InsertTimeCommand(), cancellationToken);
|
||||
if (result == null)
|
||||
return NotFound();
|
||||
|
||||
return Ok(result);
|
||||
}
|
||||
}
|
||||
@@ -54,6 +54,7 @@ builder.Services.AddApplication();
|
||||
builder.Services.AddScoped<ICatalogRepository, CatalogRepository>();
|
||||
builder.Services.AddScoped<IMassDataRepository, MassDataRepository>();
|
||||
builder.Services.AddScoped<ILayoutRepository, LayoutRepository>();
|
||||
builder.Services.AddScoped<ITimeRepository, TimeRepository>();
|
||||
|
||||
builder.Services.AddDevExpressControls();
|
||||
builder.Services.AddSignalR();
|
||||
|
||||
Reference in New Issue
Block a user