This commit is contained in:
Paul Schneider 2026-07-06 00:47:35 +01:00
commit 6ac264fa2c
8 changed files with 42 additions and 31 deletions

View file

@ -205,6 +205,16 @@ public class YavscApiClient : IAsyncDisposable
return dto!;
}
/// <summary>
/// Call a JSON endpoint with no request body while still allowing a
/// positional cancellation token argument.
/// </summary>
public Task<T> CallAsync<T>(
HttpMethod method,
string path,
CancellationToken ct)
=> CallAsync<T>(method, path, body: null, ct);
/// <summary>Call an endpoint that returns no useful body (DELETE, etc.).</summary>
public async Task CallAsync(
HttpMethod method,
@ -216,6 +226,16 @@ public class YavscApiClient : IAsyncDisposable
response.EnsureSuccessStatusCode();
}
/// <summary>
/// Call an endpoint with no request body while still allowing a
/// positional cancellation token argument.
/// </summary>
public Task CallAsync(
HttpMethod method,
string path,
CancellationToken ct)
=> CallAsync(method, path, body: null, ct);
private async Task<HttpResponseMessage> SendAsync(
HttpMethod method, string path, object? body, CancellationToken ct)
{

View file

@ -9,12 +9,9 @@ namespace Yavsc
public enum QueryStatus: int
{
Inserted,
OwnerValidated,
Visited,
Rejected,
Accepted,
InProgress,
// final states
Failed,
Success

View file

@ -1,19 +1,24 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Rendering;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Localization;
using Yavsc.Models;
using Yavsc.Models.Workflow;
using Yavsc.Server.Helpers;
using Yavsc.Services;
namespace Yavsc.Controllers
{
public class CommandFormsController : Controller
{
private readonly ApplicationDbContext _context;
private readonly IStringLocalizer<CommandFormsController> _localizer;
public CommandFormsController(ApplicationDbContext context)
public CommandFormsController(ApplicationDbContext context,
IStringLocalizer<CommandFormsController> localizer)
{
_context = context;
_localizer = localizer;
}
// GET: CommandForms
@ -46,17 +51,14 @@ namespace Yavsc.Controllers
SetViewBag();
return View();
}
private void SetViewBag(CommandForm commandForm = null)
{
ViewBag.ActivityCode = new SelectList(_context.Activities, "Code", "Name", commandForm?.ActivityCode);
ViewBag.ActionName = new SelectList(
new[]{
new SelectListItem { Value = "Create", Text = "Create" },
new SelectListItem { Value = "Update", Text = "Update" },
new SelectListItem { Value = "Delete", Text = "Delete" }
});
ViewBag.ActionName = BillingService.Billing.Keys
.Select((string b) => new SelectListItem { Value = b, Text = _localizer[b] }).ToList();
}
// POST: CommandForms/Create
[HttpPost]
[ValidateAntiForgeryToken]

View file

@ -36,16 +36,16 @@ namespace Yavsc.Controllers
public ActionResult Index()
{
var uid = User.FindFirstValue(ClaimTypes.NameIdentifier);
var now = DateTime.Now;
var now = DateTime.UtcNow;
var model = new FrontOfficeIndexViewModel
{
EstimateToProduceCount = _context.RdvQueries.Where(c => c.PerformerId == uid && c.EventDate > now
&& c.ValidationDate == null && !_context.Estimates.Any(e => (e.CommandId == c.Id && e.ProviderValidationDate != null))).Count(),
EstimateToSignAsProCount = _context.RdvQueries.Where(c => (c.PerformerId == uid && c.EventDate > now
&& c.ValidationDate == null && _context.Estimates.Any(e => (e.CommandId == c.Id && e.ProviderValidationDate != null)))).Count(),
EstimateToSignAsCliCount = _context.Estimates.Where(e => e.ClientId == uid && e.ClientValidationDate == null).Count(),
BillToSignAsProCount = 0,
EstimateToProduceCount = _context.RdvQueries.Where(c => c.PerformerId == uid && c.EventDate > now && c.Status == QueryStatus.Inserted
&& c.ValidationDate == null && !_context.Estimates.Any(e => e.CommandId == c.Id)).Count(),
EstimateToHonorAsProCount = _context.RdvQueries.Where(c => c.PerformerId == uid && c.EventDate > now && c.Status == QueryStatus.Accepted
&& c.ValidationDate == null && _context.Estimates.Any(e => e.CommandId == c.Id )).Count(),
EstimateToSignAsCliCount = _context.Estimates.Where(e => e.ClientId == uid && e.Query.Status == QueryStatus.Accepted).Count(),
BillToSignAsCliCount = 0,
NewPayementsCount = 0
};

View file

@ -1,8 +1,5 @@

using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Reflection;
using Microsoft.AspNetCore.Mvc.Rendering;
using Microsoft.Extensions.Localization;

View file

@ -13,7 +13,7 @@
<dt>EstimateToSignAsPro
</dt>
<dd>@Html.DisplayFor(m=>m.EstimateToSignAsProCount)
<dd>@Html.DisplayFor(m=>m.EstimateToHonorAsProCount)
</dd>
<dt>EstimateToSignAsCli
@ -21,11 +21,6 @@
<dd>@Html.DisplayFor(m=>m.EstimateToSignAsCliCount)
</dd>
<dt>BillToSignAsPro
</dt>
<dd>@Html.DisplayFor(m=>m.BillToSignAsProCount)
</dd>
<dt>BillToSignAsCli
</dt>
<dd>@Html.DisplayFor(m=>m.BillToSignAsCliCount)

View file

@ -55,6 +55,7 @@ namespace Yavsc.Helpers
throw new InvalidOperationException($"Billing setup: code '{code}' already registered with different type");
}
BillingService.Billing.Add(code, getter);
BillingService.GlobalBillingMap.Add(typeName, code);
}
}

View file

@ -3,9 +3,8 @@ namespace Yavsc.ViewModels.FrontOffice
public class FrontOfficeIndexViewModel
{
public int EstimateToProduceCount { get; set; }
public int EstimateToSignAsProCount { get; set; }
public int EstimateToHonorAsProCount { get; set; }
public int EstimateToSignAsCliCount { get; set; }
public int BillToSignAsProCount { get; set; }
public int BillToSignAsCliCount { get; set; }
public int NewPayementsCount { get; set; }