WIP separation Web et API
This commit is contained in:
parent
1d6cad7bef
commit
49826eae4a
55 changed files with 68 additions and 95 deletions
56
src/Api/Controllers/Business/FrontOfficeApiController.cs
Normal file
56
src/Api/Controllers/Business/FrontOfficeApiController.cs
Normal 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();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue