| | | 1 | | using Microsoft.AspNetCore.Authorization; |
| | | 2 | | using Microsoft.AspNetCore.Mvc; |
| | | 3 | | using Services.ApiServices.ApiSupplierRequestLog; |
| | | 4 | | using Services.ApiServices.AvdApi; |
| | | 5 | | |
| | | 6 | | namespace OzonOrdersWeb.Areas.Studio2.Controllers.Directories; |
| | | 7 | | |
| | | 8 | | [Area("Studio2")] |
| | | 9 | | [Authorize(Roles = "User,Admin")] |
| | | 10 | | [Route("Avd/[action]")] |
| | | 11 | | public sealed class AvdController : Controller |
| | | 12 | | { |
| | | 13 | | private readonly AvdDataManager _avd; |
| | | 14 | | private readonly ApiSupplierRequestLogStore _logs; |
| | 0 | 15 | | public AvdController(AvdDataManager avd, ApiSupplierRequestLogStore logs) { _avd = avd; _logs = logs; } |
| | 0 | 16 | | [HttpGet, Route("~/Avd")] public IActionResult Index() => View(); |
| | 0 | 17 | | [HttpGet] public IActionResult Logs() => Json(_logs.Get("Avd")); |
| | 0 | 18 | | [HttpGet] public async Task<IActionResult> UserStatus(CancellationToken ct) => await XmlAsync(() => _avd.GetUserStat |
| | 0 | 19 | | [HttpGet] public async Task<IActionResult> Basket(CancellationToken ct) => await XmlAsync(() => _avd.GetBasketItemAs |
| | 0 | 20 | | [HttpGet] public async Task<IActionResult> Balance(CancellationToken ct) => await XmlAsync(() => _avd.GetBalanceAsyn |
| | 0 | 21 | | [HttpGet] public async Task<IActionResult> Orders(string? dateBegin, string? dateEnd, int status = 0, string? number |
| | 0 | 22 | | [HttpGet] public async Task<IActionResult> Catalogs(string number, CancellationToken ct) => Json(await _avd.GetCatal |
| | 0 | 23 | | [HttpGet] public async Task<IActionResult> OriginalPrice(string number, string? catalog, string? supplier, Cancellat |
| | 0 | 24 | | [HttpGet] public async Task<IActionResult> FastCrossesPrice(string number, string catalog, string? supplier, Cancell |
| | 0 | 25 | | [HttpGet] public async Task<IActionResult> CrossesPrice(string number, string? catalog, string? supplier, Cancellati |
| | | 26 | | private async Task<IActionResult> XmlAsync(Func<Task<System.Xml.Linq.XElement>> call) |
| | | 27 | | { |
| | 0 | 28 | | try { return Content((await call()).ToString(), "application/xml"); } |
| | 0 | 29 | | catch (AvdApiException ex) { return BadRequest(new { error = true, message = ex.Message }); } |
| | 0 | 30 | | } |
| | | 31 | | } |