WIP separation Web et API

This commit is contained in:
Paul Schneider 2025-02-12 20:41:14 +00:00
commit 49826eae4a
55 changed files with 68 additions and 95 deletions

View file

@ -0,0 +1,56 @@
using System;
using System.Collections.Generic;
using Microsoft.AspNetCore.Mvc;
using Yavsc.Helpers;
using Yavsc.Models;
using Yavsc.Services;
using Yavsc.ViewModels.FrontOffice;
namespace Yavsc.ApiControllers
{
[Route("api/front")]
public class FrontOfficeApiController : Controller
{
ApplicationDbContext dbContext;
private IBillingService billing;
public FrontOfficeApiController(ApplicationDbContext context, IBillingService billing)
{
dbContext = context;
this.billing = billing;
}
[HttpGet("profiles/{actCode}")]
IEnumerable<PerformerProfileViewModel> Profiles(string actCode)
{
return dbContext.ListPerformers(billing, actCode);
}
[HttpPost("query/reject")]
public IActionResult RejectQuery(string billingCode, long queryId)
{
if (billingCode == null) return BadRequest("billingCode");
if (queryId == 0) return BadRequest("queryId");
var billing = BillingService.GetBillable(dbContext, billingCode, queryId);
if (billing == null) return BadRequest();
billing.Decided = true;
billing.Accepted = false;
dbContext.SaveChanges();
return Ok();
}
[HttpPost("query/reject")]
public IActionResult AcceptQuery(string billingCode, long queryId)
{
if (billingCode == null) return BadRequest("billingCode");
if (queryId == 0) return BadRequest("queryId");
var billing = BillingService.GetBillable(dbContext, billingCode, queryId);
if (billing == null) return BadRequest();
billing.Accepted = true;
billing.Decided = true;
dbContext.SaveChanges();
return Ok();
}
}
}