yavsc/src/Yavsc/ApiControllers/Business/FrontOfficeApiController.cs

43 lines
1.3 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;
using Microsoft.AspNet.Mvc;
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}")]
IEnumerable<PerformerProfileViewModel> Profiles(string actCode)
2017-02-03 15:25:47 +01:00
{
2018-06-15 15:44:21 +02:00
return dbContext.ListPerformers(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
{
2020-10-09 19:35:39 +01:00
if (billingCode == null) return HttpBadRequest("billingCode");
if (queryId == 0) return HttpBadRequest("queryId");
var billing = BillingService.GetBillable(dbContext, billingCode, queryId);
if (billing == null) return HttpBadRequest();
2018-02-25 03:33:54 +01:00
billing.Rejected = true;
billing.RejectedAt = DateTime.Now;
dbContext.SaveChanges();
return Ok();
}
2017-02-03 15:25:47 +01:00
}
}