ac3f34e4f3
Added .gitignore, solution, and project files for .NET 10. Introduced AGENTS.md and PLAN.md for guidelines and planning. Implemented appsettings.json, launchSettings.json, and MySQL config. Created AppDBContext and all domain models with composite keys. Added IUnitOfWork and EFUnitOfWork. Structured feature folders for Region, Route, Vehicle, Store, Warehouse, and Order with DTOs, repositories, services, and controllers. Added initial EF Core migrations and sample HTTP request. Registered dependencies and enabled OpenAPI in development.
41 lines
1.2 KiB
C#
41 lines
1.2 KiB
C#
using Microsoft.AspNetCore.Mvc;
|
|
|
|
namespace Distribution.Features.Store;
|
|
|
|
[ApiController]
|
|
[Route("api/stores")]
|
|
public class StoreController(StoreService service) : ControllerBase
|
|
{
|
|
[HttpGet]
|
|
public async Task<IActionResult> GetAll() =>
|
|
Ok(await service.GetAllAsync());
|
|
|
|
[HttpGet("{id:guid}")]
|
|
public async Task<IActionResult> GetById(Guid id)
|
|
{
|
|
var result = await service.GetByIdAsync(id);
|
|
return result is null ? NotFound() : Ok(result);
|
|
}
|
|
|
|
[HttpPost]
|
|
public async Task<IActionResult> Create(CreateStoreRequest request, CancellationToken ct)
|
|
{
|
|
var result = await service.CreateAsync(request, ct);
|
|
return CreatedAtAction(nameof(GetById), new { id = result.Id }, result);
|
|
}
|
|
|
|
[HttpPut("{id:guid}")]
|
|
public async Task<IActionResult> Update(Guid id, UpdateStoreRequest request, CancellationToken ct)
|
|
{
|
|
var result = await service.UpdateAsync(id, request, ct);
|
|
return result is null ? NotFound() : Ok(result);
|
|
}
|
|
|
|
[HttpDelete("{id:guid}")]
|
|
public async Task<IActionResult> Delete(Guid id, CancellationToken ct)
|
|
{
|
|
var deleted = await service.DeleteAsync(id, ct);
|
|
return deleted ? NoContent() : NotFound();
|
|
}
|
|
}
|