tests
This commit is contained in:
parent
c08ff81776
commit
6ac264fa2c
8 changed files with 42 additions and 31 deletions
|
|
@ -205,6 +205,16 @@ public class YavscApiClient : IAsyncDisposable
|
||||||
return dto!;
|
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>
|
/// <summary>Call an endpoint that returns no useful body (DELETE, etc.).</summary>
|
||||||
public async Task CallAsync(
|
public async Task CallAsync(
|
||||||
HttpMethod method,
|
HttpMethod method,
|
||||||
|
|
@ -216,6 +226,16 @@ public class YavscApiClient : IAsyncDisposable
|
||||||
response.EnsureSuccessStatusCode();
|
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(
|
private async Task<HttpResponseMessage> SendAsync(
|
||||||
HttpMethod method, string path, object? body, CancellationToken ct)
|
HttpMethod method, string path, object? body, CancellationToken ct)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -9,12 +9,9 @@ namespace Yavsc
|
||||||
public enum QueryStatus: int
|
public enum QueryStatus: int
|
||||||
{
|
{
|
||||||
Inserted,
|
Inserted,
|
||||||
OwnerValidated,
|
|
||||||
Visited,
|
|
||||||
Rejected,
|
Rejected,
|
||||||
Accepted,
|
Accepted,
|
||||||
InProgress,
|
InProgress,
|
||||||
|
|
||||||
// final states
|
// final states
|
||||||
Failed,
|
Failed,
|
||||||
Success
|
Success
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,24 @@
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.Extensions.Localization;
|
||||||
using Yavsc.Models;
|
using Yavsc.Models;
|
||||||
using Yavsc.Models.Workflow;
|
using Yavsc.Models.Workflow;
|
||||||
using Yavsc.Server.Helpers;
|
using Yavsc.Server.Helpers;
|
||||||
|
using Yavsc.Services;
|
||||||
|
|
||||||
namespace Yavsc.Controllers
|
namespace Yavsc.Controllers
|
||||||
{
|
{
|
||||||
public class CommandFormsController : Controller
|
public class CommandFormsController : Controller
|
||||||
{
|
{
|
||||||
private readonly ApplicationDbContext _context;
|
private readonly ApplicationDbContext _context;
|
||||||
|
private readonly IStringLocalizer<CommandFormsController> _localizer;
|
||||||
|
|
||||||
public CommandFormsController(ApplicationDbContext context)
|
public CommandFormsController(ApplicationDbContext context,
|
||||||
|
IStringLocalizer<CommandFormsController> localizer)
|
||||||
{
|
{
|
||||||
_context = context;
|
_context = context;
|
||||||
|
_localizer = localizer;
|
||||||
}
|
}
|
||||||
|
|
||||||
// GET: CommandForms
|
// GET: CommandForms
|
||||||
|
|
@ -46,17 +51,14 @@ namespace Yavsc.Controllers
|
||||||
SetViewBag();
|
SetViewBag();
|
||||||
return View();
|
return View();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetViewBag(CommandForm commandForm = null)
|
private void SetViewBag(CommandForm commandForm = null)
|
||||||
{
|
{
|
||||||
ViewBag.ActivityCode = new SelectList(_context.Activities, "Code", "Name", commandForm?.ActivityCode);
|
ViewBag.ActivityCode = new SelectList(_context.Activities, "Code", "Name", commandForm?.ActivityCode);
|
||||||
ViewBag.ActionName = new SelectList(
|
ViewBag.ActionName = BillingService.Billing.Keys
|
||||||
new[]{
|
.Select((string b) => new SelectListItem { Value = b, Text = _localizer[b] }).ToList();
|
||||||
new SelectListItem { Value = "Create", Text = "Create" },
|
|
||||||
new SelectListItem { Value = "Update", Text = "Update" },
|
|
||||||
new SelectListItem { Value = "Delete", Text = "Delete" }
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// POST: CommandForms/Create
|
// POST: CommandForms/Create
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[ValidateAntiForgeryToken]
|
[ValidateAntiForgeryToken]
|
||||||
|
|
|
||||||
|
|
@ -36,16 +36,16 @@ namespace Yavsc.Controllers
|
||||||
public ActionResult Index()
|
public ActionResult Index()
|
||||||
{
|
{
|
||||||
var uid = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
var uid = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
||||||
var now = DateTime.Now;
|
var now = DateTime.UtcNow;
|
||||||
|
|
||||||
var model = new FrontOfficeIndexViewModel
|
var model = new FrontOfficeIndexViewModel
|
||||||
{
|
{
|
||||||
EstimateToProduceCount = _context.RdvQueries.Where(c => c.PerformerId == uid && c.EventDate > now
|
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 && e.ProviderValidationDate != null))).Count(),
|
&& c.ValidationDate == null && !_context.Estimates.Any(e => e.CommandId == c.Id)).Count(),
|
||||||
EstimateToSignAsProCount = _context.RdvQueries.Where(c => (c.PerformerId == uid && c.EventDate > now
|
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 && e.ProviderValidationDate != null)))).Count(),
|
&& c.ValidationDate == null && _context.Estimates.Any(e => e.CommandId == c.Id )).Count(),
|
||||||
EstimateToSignAsCliCount = _context.Estimates.Where(e => e.ClientId == uid && e.ClientValidationDate == null).Count(),
|
EstimateToSignAsCliCount = _context.Estimates.Where(e => e.ClientId == uid && e.Query.Status == QueryStatus.Accepted).Count(),
|
||||||
BillToSignAsProCount = 0,
|
|
||||||
BillToSignAsCliCount = 0,
|
BillToSignAsCliCount = 0,
|
||||||
NewPayementsCount = 0
|
NewPayementsCount = 0
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,5 @@
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.Linq;
|
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||||
using Microsoft.Extensions.Localization;
|
using Microsoft.Extensions.Localization;
|
||||||
|
|
@ -23,7 +20,7 @@ namespace Yavsc.Extensions
|
||||||
var typeInfo = type.GetTypeInfo();
|
var typeInfo = type.GetTypeInfo();
|
||||||
var values = Enum.GetValues(type).Cast<Enum>();
|
var values = Enum.GetValues(type).Cast<Enum>();
|
||||||
var items = new List<SelectListItem>();
|
var items = new List<SelectListItem>();
|
||||||
|
|
||||||
foreach (var value in values)
|
foreach (var value in values)
|
||||||
{
|
{
|
||||||
items.Add(new SelectListItem {
|
items.Add(new SelectListItem {
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@
|
||||||
|
|
||||||
<dt>EstimateToSignAsPro
|
<dt>EstimateToSignAsPro
|
||||||
</dt>
|
</dt>
|
||||||
<dd>@Html.DisplayFor(m=>m.EstimateToSignAsProCount)
|
<dd>@Html.DisplayFor(m=>m.EstimateToHonorAsProCount)
|
||||||
</dd>
|
</dd>
|
||||||
|
|
||||||
<dt>EstimateToSignAsCli
|
<dt>EstimateToSignAsCli
|
||||||
|
|
@ -21,11 +21,6 @@
|
||||||
<dd>@Html.DisplayFor(m=>m.EstimateToSignAsCliCount)
|
<dd>@Html.DisplayFor(m=>m.EstimateToSignAsCliCount)
|
||||||
</dd>
|
</dd>
|
||||||
|
|
||||||
<dt>BillToSignAsPro
|
|
||||||
</dt>
|
|
||||||
<dd>@Html.DisplayFor(m=>m.BillToSignAsProCount)
|
|
||||||
</dd>
|
|
||||||
|
|
||||||
<dt>BillToSignAsCli
|
<dt>BillToSignAsCli
|
||||||
</dt>
|
</dt>
|
||||||
<dd>@Html.DisplayFor(m=>m.BillToSignAsCliCount)
|
<dd>@Html.DisplayFor(m=>m.BillToSignAsCliCount)
|
||||||
|
|
|
||||||
|
|
@ -55,6 +55,7 @@ namespace Yavsc.Helpers
|
||||||
throw new InvalidOperationException($"Billing setup: code '{code}' already registered with different type");
|
throw new InvalidOperationException($"Billing setup: code '{code}' already registered with different type");
|
||||||
}
|
}
|
||||||
BillingService.Billing.Add(code, getter);
|
BillingService.Billing.Add(code, getter);
|
||||||
|
BillingService.GlobalBillingMap.Add(typeName, code);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,11 +3,10 @@ namespace Yavsc.ViewModels.FrontOffice
|
||||||
public class FrontOfficeIndexViewModel
|
public class FrontOfficeIndexViewModel
|
||||||
{
|
{
|
||||||
public int EstimateToProduceCount { get; set; }
|
public int EstimateToProduceCount { get; set; }
|
||||||
public int EstimateToSignAsProCount { get; set; }
|
public int EstimateToHonorAsProCount { get; set; }
|
||||||
public int EstimateToSignAsCliCount { get; set; }
|
public int EstimateToSignAsCliCount { get; set; }
|
||||||
public int BillToSignAsProCount { get; set; }
|
|
||||||
public int BillToSignAsCliCount { get; set; }
|
public int BillToSignAsCliCount { get; set; }
|
||||||
public int NewPayementsCount { get; set; }
|
public int NewPayementsCount { get; set; }
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue