15def7ff1c
CI/CD / CI · API (dotnet build + test) (push) Successful in 1m10s
CI/CD / CI · Admin API (dotnet build) (push) Successful in 52s
CI/CD / CI · Dashboard (tsc) (push) Successful in 1m5s
CI/CD / CI · Admin Web (tsc) (push) Successful in 35s
CI/CD / CI · Website (tsc) (push) Successful in 45s
CI/CD / CI · Koja (tsc) (push) Successful in 55s
CI/CD / Deploy · all services (push) Successful in 3m29s
Delete (every manageable entity that only had "add" now has delete):
- Ingredients (warehouse): new DELETE /inventory/ingredients/{id} (soft-delete via
the global DeletedAt filter — no FK trouble with recipes/movements) + NoOp stub +
trash button in the materials cards.
- Reservations: new DELETE /reservations/{id} (soft-delete) + per-card delete button.
- Coupons & Customers: backend DELETE already existed; wired delete buttons in the UI.
- Shared ConfirmDialog component used by all delete flows (RTL-aware).
- Audit result: tables/branches/taxes/kitchen-stations/expenses/menu/terminals already
had delete; HR has no "add" so no delete needed; shifts intentionally excluded
(financial open/close records, not add-style entities).
Koja visibility:
- New Cafe.ShowOnKoja flag, default TRUE (DB default true so existing cafés stay
listed). Discover query now filters IsVerified && !Deleted && ShowOnKoja.
- public-profile GET/PUT expose showOnKoja; dashboard public-profile panel has an
on-by-default toggle that persists immediately. Platform IsVerified gate unchanged.
- EF migration AddCafeShowOnKoja (defaultValue: true).
Also: added the missing errors.generic i18n key (fa/en/ar) so useApiError's fallback
resolves instead of rendering the literal "errors.generic". 81 API tests pass.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
85 lines
2.9 KiB
C#
85 lines
2.9 KiB
C#
using FluentValidation;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Meezi.API.Models.Public;
|
|
using Meezi.API.Services;
|
|
using Meezi.Core.Enums;
|
|
using Meezi.Core.Interfaces;
|
|
using Meezi.Shared;
|
|
|
|
namespace Meezi.API.Controllers;
|
|
|
|
[Route("api/cafes/{cafeId}/reservations")]
|
|
public class ReservationsController : CafeApiControllerBase
|
|
{
|
|
private readonly IReservationService _reservations;
|
|
private readonly IValidator<CreateReservationRequest> _createValidator;
|
|
|
|
public ReservationsController(
|
|
IReservationService reservations,
|
|
IValidator<CreateReservationRequest> createValidator)
|
|
{
|
|
_reservations = reservations;
|
|
_createValidator = createValidator;
|
|
}
|
|
|
|
[HttpPost]
|
|
public async Task<IActionResult> Create(
|
|
string cafeId,
|
|
[FromBody] CreateReservationRequest request,
|
|
ITenantContext tenant,
|
|
CancellationToken ct)
|
|
{
|
|
if (EnsureCafeAccess(cafeId, tenant) is { } denied) return denied;
|
|
var validation = await _createValidator.ValidateAsync(request, ct);
|
|
if (!validation.IsValid) return BadRequest(ValidationError(validation));
|
|
|
|
var data = await _reservations.CreateAsync(cafeId, request, ct);
|
|
if (data is null)
|
|
return BadRequest(new ApiResponse<object>(false, null, new ApiError("INVALID_TABLE", "Table not found.")));
|
|
|
|
return Ok(new ApiResponse<ReservationDto>(true, data));
|
|
}
|
|
|
|
[HttpGet]
|
|
public async Task<IActionResult> List(
|
|
string cafeId,
|
|
ITenantContext tenant,
|
|
[FromQuery] DateOnly? date,
|
|
[FromQuery] ReservationStatus? status,
|
|
CancellationToken ct)
|
|
{
|
|
if (EnsureCafeAccess(cafeId, tenant) is { } denied) return denied;
|
|
var data = await _reservations.GetReservationsAsync(cafeId, date, status, ct);
|
|
return Ok(new ApiResponse<IReadOnlyList<ReservationDto>>(true, data));
|
|
}
|
|
|
|
[HttpPatch("{id}/status")]
|
|
public async Task<IActionResult> UpdateStatus(
|
|
string cafeId,
|
|
string id,
|
|
[FromBody] UpdateReservationStatusRequest request,
|
|
ITenantContext tenant,
|
|
CancellationToken ct)
|
|
{
|
|
if (EnsureCafeAccess(cafeId, tenant) is { } denied) return denied;
|
|
var data = await _reservations.UpdateStatusAsync(cafeId, id, request.Status, ct);
|
|
if (data is null) return NotFoundError();
|
|
return Ok(new ApiResponse<ReservationDto>(true, data));
|
|
}
|
|
|
|
[HttpDelete("{id}")]
|
|
public async Task<IActionResult> Delete(
|
|
string cafeId,
|
|
string id,
|
|
ITenantContext tenant,
|
|
CancellationToken ct)
|
|
{
|
|
if (EnsureCafeAccess(cafeId, tenant) is { } denied) return denied;
|
|
var deleted = await _reservations.DeleteAsync(cafeId, id, ct);
|
|
if (!deleted) return NotFoundError();
|
|
return Ok(new ApiResponse<object>(true, new { id }));
|
|
}
|
|
}
|
|
|
|
public record UpdateReservationStatusRequest(ReservationStatus Status);
|