Aggiunto ricalcolo anche importo totale offerta
This commit is contained in:
@@ -236,7 +236,7 @@ namespace EgwCoreLib.Lux.Data.Controllers
|
||||
/// Elenco completo offerte da DB
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public List<OfferModel> OfferGetAll()
|
||||
public async Task<List<OfferModel>> OfferGetAll()
|
||||
{
|
||||
List<OfferModel> dbResult = new List<OfferModel>();
|
||||
//using (DataLayerContext dbCtx = new DataLayerContext(configuration))
|
||||
@@ -244,11 +244,12 @@ namespace EgwCoreLib.Lux.Data.Controllers
|
||||
{
|
||||
try
|
||||
{
|
||||
dbResult = dbCtx
|
||||
.DbSetOffer
|
||||
.Include(c => c.CustomerNav)
|
||||
.Include(d => d.DealerNav)
|
||||
.ToList();
|
||||
dbResult = await dbCtx
|
||||
.DbSetOffer
|
||||
.Include(c => c.CustomerNav)
|
||||
.Include(d => d.DealerNav)
|
||||
.Include(o => o.OfferRowNav)
|
||||
.ToListAsync();
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
|
||||
@@ -83,6 +83,24 @@ namespace EgwCoreLib.Lux.Data.DbModel
|
||||
/// </summary>
|
||||
public OfferStates OffertState { get; set; } = OfferStates.Open;
|
||||
|
||||
/// <summary>
|
||||
/// Numero Item compresi
|
||||
/// </summary>
|
||||
[NotMapped]
|
||||
public int NumItems
|
||||
{
|
||||
get => OfferRowNav?.Count ?? 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Imposto totale offerta
|
||||
/// </summary>
|
||||
[NotMapped]
|
||||
public double TotalCost
|
||||
{
|
||||
get => OfferRowNav?.Sum(x => x.Cost) ?? 0;
|
||||
}
|
||||
|
||||
#if false
|
||||
/// <summary>
|
||||
/// ID Ordine (nullo se non c'è ordine)
|
||||
@@ -107,5 +125,10 @@ namespace EgwCoreLib.Lux.Data.DbModel
|
||||
/// </summary>
|
||||
[ForeignKey("DealerID")]
|
||||
public virtual DealerModel DealerNav { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// Navigazione alle righe offerta
|
||||
/// </summary>
|
||||
public virtual ICollection<OfferRowModel> OfferRowNav { get; set; } = new List<OfferRowModel>();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -150,7 +150,7 @@ namespace EgwCoreLib.Lux.Data.Services
|
||||
/// Elenco completo offerte da DB
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public List<OfferModel> OfferGetAll()
|
||||
public async Task<List<OfferModel>> OfferGetAll()
|
||||
{
|
||||
string source = "DB";
|
||||
Stopwatch sw = new Stopwatch();
|
||||
@@ -158,7 +158,7 @@ namespace EgwCoreLib.Lux.Data.Services
|
||||
List<OfferModel>? result = new List<OfferModel>();
|
||||
// cerco in redis...
|
||||
string currKey = $"{redisBaseKey}:Offers:ALL";
|
||||
RedisValue rawData = redisDb.StringGet(currKey);
|
||||
RedisValue rawData = await redisDb.StringGetAsync(currKey);
|
||||
//if (!string.IsNullOrEmpty($"{rawData}"))
|
||||
if (rawData.HasValue)
|
||||
{
|
||||
@@ -167,10 +167,10 @@ namespace EgwCoreLib.Lux.Data.Services
|
||||
}
|
||||
else
|
||||
{
|
||||
result = dbController.OfferGetAll();
|
||||
// serializzo e salvo...
|
||||
rawData = JsonConvert.SerializeObject(result);
|
||||
redisDb.StringSet(currKey, rawData, LongCache);
|
||||
result = await dbController.OfferGetAll();
|
||||
// serializzo e salvo con config x evitare loop...
|
||||
rawData = JsonConvert.SerializeObject(result, JSSettings);
|
||||
await redisDb.StringSetAsync(currKey, rawData, LongCache);
|
||||
}
|
||||
if (result == null)
|
||||
{
|
||||
|
||||
@@ -161,8 +161,12 @@ else
|
||||
{
|
||||
<td>@item.Description</td>
|
||||
}
|
||||
<td class="text-end">...</td>
|
||||
<td class="text-end">---</td>
|
||||
<td class="text-end">
|
||||
@item.NumItems
|
||||
</td>
|
||||
<td class="text-end">
|
||||
@item.TotalCost.ToString("C2")
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
|
||||
@@ -76,10 +76,10 @@ namespace Lux.UI.Components.Pages
|
||||
SelRecord = curRec;
|
||||
}
|
||||
|
||||
protected override void OnInitialized()
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
SetupArrows();
|
||||
ReloadData();
|
||||
await ReloadData();
|
||||
UpdateTable();
|
||||
}
|
||||
|
||||
@@ -148,9 +148,9 @@ namespace Lux.UI.Components.Pages
|
||||
/// <summary>
|
||||
/// Legge i dati dei record completi
|
||||
/// </summary>
|
||||
private void ReloadData()
|
||||
private async Task ReloadData()
|
||||
{
|
||||
AllRecords = DLService.OfferGetAll();
|
||||
AllRecords = await DLService.OfferGetAll();
|
||||
totalCount = AllRecords.Count();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user