yavsc/src/Yavsc.Api/Controllers/Business/FrontOfficeApiController.cs

55 lines
1.8 KiB
C#
Raw Normal View History

2018-02-25 03:33:54 +01:00
using System;
2017-02-03 15:25:47 +01:00
using System.Collections.Generic;
2023-03-19 17:57:55 +00:00
using Microsoft.AspNetCore.Mvc;
2017-02-03 15:25:47 +01:00
using Yavsc.Helpers;
using Yavsc.Models;
2018-03-26 19:27:29 +02:00
using Yavsc.Services;
2018-06-15 15:44:21 +02:00
using Yavsc.ViewModels.FrontOffice;
2017-02-03 15:25:47 +01:00
namespace Yavsc.ApiControllers
{
[Route("api/front")]
2020-10-09 19:35:39 +01:00
public class FrontOfficeApiController : Controller
2017-02-03 15:25:47 +01:00
{
ApplicationDbContext dbContext;
2020-10-09 19:35:39 +01:00
2018-06-15 15:44:21 +02:00
private IBillingService billing;
public FrontOfficeApiController(ApplicationDbContext context, IBillingService billing)
2017-02-03 15:25:47 +01:00
{
dbContext = context;
2018-06-15 15:44:21 +02:00
this.billing = billing;
2017-02-03 15:25:47 +01:00
}
2020-10-09 19:35:39 +01:00
[HttpGet("profiles/{actCode}")]
2025-02-24 23:29:48 +00:00
async Task <IEnumerable<PerformerProfileViewModel>> Profiles(string actCode)
2017-02-03 15:25:47 +01:00
{
2025-02-24 23:29:48 +00:00
return await dbContext.ListPerformersAsync(billing, actCode);
2017-02-03 15:25:47 +01:00
}
2018-02-25 03:33:54 +01:00
2018-06-15 15:44:21 +02:00
[HttpPost("query/reject")]
2020-10-09 19:35:39 +01:00
public IActionResult RejectQuery(string billingCode, long queryId)
2018-02-25 03:33:54 +01:00
{
2023-03-19 17:57:55 +00:00
if (billingCode == null) return BadRequest("billingCode");
if (queryId == 0) return BadRequest("queryId");
2020-10-09 19:35:39 +01:00
var billing = BillingService.GetBillable(dbContext, billingCode, queryId);
2023-03-19 17:57:55 +00:00
if (billing == null) return BadRequest();
2026-07-04 22:35:53 +01:00
billing.Status = QueryStatus.Rejected;
2018-02-25 03:33:54 +01:00
dbContext.SaveChanges();
return Ok();
}
2025-02-24 23:29:48 +00:00
2025-06-29 19:53:19 +01:00
[HttpPost("query/accept")]
2024-02-25 18:05:10 +00:00
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();
2026-07-04 22:35:53 +01:00
billing.Status = QueryStatus.Accepted;
2024-02-25 18:05:10 +00:00
dbContext.SaveChanges();
return Ok();
}
2017-02-03 15:25:47 +01:00
}
}