item details inizio pagina
This commit is contained in:
@@ -36,12 +36,12 @@ else
|
||||
{
|
||||
<tr class="small">
|
||||
<td class="d-flex justify-content-center">
|
||||
<button class="btnDet"><i class="fa-solid fa-magnifying-glass-plus"></i></button>
|
||||
<button class="btnDet" @onclick="()=>selItemToDet(item.Id)"><i class="fa-solid fa-magnifying-glass-plus"></i></button>
|
||||
</td>
|
||||
<td>
|
||||
@item.CodInt
|
||||
</td>
|
||||
<td style="max-width: 20rem;">
|
||||
<td style="width: 34rem;">
|
||||
@item.Descr
|
||||
</td>
|
||||
<td>
|
||||
|
||||
@@ -19,8 +19,10 @@ namespace StockMan.CORE.Components
|
||||
|
||||
[Inject]
|
||||
protected StockDataService SDService { get; set; } = null!;
|
||||
|
||||
[Inject]
|
||||
protected IJSRuntime JSRuntime { get; set; } = null!;
|
||||
|
||||
[Inject]
|
||||
protected NavigationManager NavManager { get; set; } = null!;
|
||||
|
||||
@@ -70,7 +72,12 @@ namespace StockMan.CORE.Components
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Inject]
|
||||
private IConfiguration Configuration { get; set; } = null!;
|
||||
|
||||
protected bool isLoading = false;
|
||||
|
||||
private async Task reloadData()
|
||||
{
|
||||
isLoading = true;
|
||||
@@ -81,6 +88,27 @@ namespace StockMan.CORE.Components
|
||||
await InvokeAsync(() => StateHasChanged());
|
||||
isLoading = false;
|
||||
}
|
||||
}
|
||||
private void selItemToDet(int selItem)
|
||||
{
|
||||
currItem = selItem;
|
||||
NavManager.NavigateTo(rawCode, true);
|
||||
}
|
||||
protected int? _currItem;
|
||||
protected int? currItem
|
||||
{
|
||||
get=> _currItem;
|
||||
set=> _currItem = value;
|
||||
}
|
||||
|
||||
|
||||
protected string rawCode
|
||||
{
|
||||
get
|
||||
{
|
||||
string answ = "";
|
||||
answ = $"itemDetail?ItemID={currItem}";
|
||||
return answ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -275,40 +275,81 @@ namespace StockMan.CORE.Data
|
||||
Log.Debug($"ItemsGetAll | {source} in: {ts.TotalMilliseconds} ms");
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
///// <summary>
|
||||
///// Lista Articoli da ricerca
|
||||
///// </summary>
|
||||
///// <returns></returns>
|
||||
//public async Task<List<ItemModel>> ItemsGetSearch(string searchVal, string famID)
|
||||
//{
|
||||
// string source = "DB";
|
||||
// List<ItemModel>? dbResult = new List<ItemModel>();
|
||||
// string currKey = $"{rKeyItems}:Search:{searchVal}:FamilyID:{famID}";
|
||||
// Stopwatch stopWatch = new Stopwatch();
|
||||
// stopWatch.Start();
|
||||
// string? rawData = await redisDb.StringGetAsync(currKey);
|
||||
// if (!string.IsNullOrEmpty(rawData))
|
||||
// {
|
||||
// source = "REDIS";
|
||||
// var tempResult = JsonConvert.DeserializeObject<List<ItemModel>>(rawData);
|
||||
// if (tempResult == null)
|
||||
// {
|
||||
// dbResult = new List<ItemModel>();
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// dbResult = tempResult;
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// dbResult = dbController.ItemsGetSearch(searchVal, famID);
|
||||
// rawData = JsonConvert.SerializeObject(dbResult, JSSettings);
|
||||
// await redisDb.StringSetAsync(currKey, rawData, LongCache);
|
||||
// }
|
||||
// if (dbResult == null)
|
||||
// {
|
||||
// dbResult = new List<ItemModel>();
|
||||
// }
|
||||
// stopWatch.Stop();
|
||||
// TimeSpan ts = stopWatch.Elapsed;
|
||||
// Log.Debug($"ItemsGetSearch | {source} in: {ts.TotalMilliseconds} ms");
|
||||
// return dbResult;
|
||||
//}
|
||||
/// <summary>
|
||||
/// Lista Articoli da ricerca
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<List<ItemModel>> ItemsGetSearch(string searchVal, string famID)
|
||||
public async Task<ItemModel> ItemsGetSearch(int id)
|
||||
{
|
||||
string source = "DB";
|
||||
List<ItemModel>? dbResult = new List<ItemModel>();
|
||||
string currKey = $"{rKeyItems}:Search:{searchVal}:FamilyID:{famID}";
|
||||
ItemModel? dbResult = new ItemModel();
|
||||
string currKey = $"{rKeyItems}:Search:{id}";
|
||||
Stopwatch stopWatch = new Stopwatch();
|
||||
stopWatch.Start();
|
||||
string? rawData = await redisDb.StringGetAsync(currKey);
|
||||
if (!string.IsNullOrEmpty(rawData))
|
||||
{
|
||||
source = "REDIS";
|
||||
var tempResult = JsonConvert.DeserializeObject<List<ItemModel>>(rawData);
|
||||
if (tempResult == null)
|
||||
{
|
||||
dbResult = new List<ItemModel>();
|
||||
}
|
||||
else
|
||||
{
|
||||
dbResult = tempResult;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dbResult = dbController.ItemsGetSearch(searchVal, famID);
|
||||
//if (!string.IsNullOrEmpty(rawData))
|
||||
//{
|
||||
// source = "REDIS";
|
||||
// var tempResult = JsonConvert.DeserializeObject<List<ItemModel>>(rawData);
|
||||
// if (tempResult == null)
|
||||
// {
|
||||
// dbResult = new ItemModel();
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// dbResult = tempResult.FirstOrDefault();
|
||||
// }
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
//}
|
||||
dbResult = dbController.ItemsGetSearch(id);
|
||||
rawData = JsonConvert.SerializeObject(dbResult, JSSettings);
|
||||
await redisDb.StringSetAsync(currKey, rawData, LongCache);
|
||||
}
|
||||
if (dbResult == null)
|
||||
{
|
||||
dbResult = new List<ItemModel>();
|
||||
dbResult = new ItemModel();
|
||||
}
|
||||
stopWatch.Stop();
|
||||
TimeSpan ts = stopWatch.Elapsed;
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
@page "/ItemDetail"
|
||||
|
||||
|
||||
@if (itemToDet != null)
|
||||
{
|
||||
<div class="d-flex justify-content-between mx-2">
|
||||
<div class="card col-3 mx-2">
|
||||
<div class="card-header">
|
||||
Dettagli articolo
|
||||
</div>
|
||||
<div class="card-body">
|
||||
</div>
|
||||
</div>
|
||||
<div class="card col-5 ">
|
||||
<div class="card-header">
|
||||
Dettagli articolo
|
||||
</div>
|
||||
<div class="card-body">
|
||||
</div>
|
||||
</div>
|
||||
<div class="card col-4 ">
|
||||
<div class="card-header">
|
||||
Dettagli articolo
|
||||
</div>
|
||||
<div class="card-body">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using System.Net.Http;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Components.Authorization;
|
||||
using Microsoft.AspNetCore.Components.Forms;
|
||||
using Microsoft.AspNetCore.Components.Routing;
|
||||
using Microsoft.AspNetCore.Components.Web;
|
||||
using Microsoft.AspNetCore.Components.Web.Virtualization;
|
||||
using Microsoft.JSInterop;
|
||||
using EgwCoreLib.Razor;
|
||||
using EgwCoreLib.Razor.Data;
|
||||
using StockMan.CORE;
|
||||
using StockMan.CORE.Data;
|
||||
using StockMan.CORE.Shared;
|
||||
using Microsoft.AspNetCore.WebUtilities;
|
||||
using Org.BouncyCastle.Ocsp;
|
||||
using MailKit;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using StockMan.Data.DbModels;
|
||||
|
||||
namespace StockMan.CORE.Pages
|
||||
{
|
||||
public partial class ItemDetail
|
||||
{
|
||||
[Inject]
|
||||
protected NavigationManager NavManager { get; set; } = null!;
|
||||
[Inject]
|
||||
protected StockDataService SDService { get; set; } = null!;
|
||||
protected ItemModel itemToDet { get; set; } = new ItemModel();
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
var uri = NavManager.ToAbsoluteUri(NavManager.Uri);
|
||||
if (QueryHelpers.ParseQuery(uri.Query).TryGetValue("ItemID", out var _itemID))
|
||||
{
|
||||
ItemID = int.Parse(_itemID);
|
||||
}
|
||||
|
||||
await reloadData();
|
||||
}
|
||||
private async Task reloadData()
|
||||
{
|
||||
itemToDet = await SDService.ItemsGetSearch(ItemID);
|
||||
await Task.Delay(1);
|
||||
}
|
||||
protected int ItemID { get; set; } = 0;
|
||||
}
|
||||
}
|
||||
@@ -236,20 +236,41 @@ namespace StockMan.Data.Controllers
|
||||
return fatto;
|
||||
}
|
||||
|
||||
///// <summary>
|
||||
///// Lista Items da ricerca
|
||||
///// </summary>
|
||||
///// <returns></returns>
|
||||
//public List<ItemModel> ItemsGetSearch(string searchVal, string famID)
|
||||
//{
|
||||
// List<ItemModel> dbResult = new List<ItemModel>();
|
||||
// using (StockManContext localDbCtx = new StockManContext(_configuration))
|
||||
// {
|
||||
// dbResult = localDbCtx
|
||||
// .DbSetItem
|
||||
// .Where(x => (x.ItemFamilyId == famID || string.IsNullOrEmpty(famID)) && (x.CodExt.Contains(searchVal) || x.Descr.Contains(searchVal) || x.DescrExt.Contains(searchVal) || string.IsNullOrEmpty(searchVal)))
|
||||
// .OrderBy(x => x.Descr)
|
||||
// .ToList();
|
||||
// }
|
||||
// return dbResult;
|
||||
//}
|
||||
/// <summary>
|
||||
/// Lista Items da ricerca
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public List<ItemModel> ItemsGetSearch(string searchVal, string famID)
|
||||
public ItemModel ItemsGetSearch(int id)
|
||||
{
|
||||
List<ItemModel> dbResult = new List<ItemModel>();
|
||||
ItemModel dbResult = new ItemModel();
|
||||
using (StockManContext localDbCtx = new StockManContext(_configuration))
|
||||
{
|
||||
dbResult = localDbCtx
|
||||
var risultato = localDbCtx
|
||||
.DbSetItem
|
||||
.Where(x => (x.ItemFamilyId == famID || string.IsNullOrEmpty(famID)) && (x.CodExt.Contains(searchVal) || x.Descr.Contains(searchVal) || x.DescrExt.Contains(searchVal) || string.IsNullOrEmpty(searchVal)))
|
||||
.OrderBy(x => x.Descr)
|
||||
.ToList();
|
||||
.Where(x => (x.Id == id))
|
||||
.FirstOrDefault();
|
||||
|
||||
if(risultato != null)
|
||||
{
|
||||
dbResult = risultato;
|
||||
}
|
||||
}
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user