diff --git a/StockMan.CORE/Components/ItemList.razor b/StockMan.CORE/Components/ItemList.razor
index 0260527..c43e7ed 100644
--- a/StockMan.CORE/Components/ItemList.razor
+++ b/StockMan.CORE/Components/ItemList.razor
@@ -36,12 +36,12 @@ else
{
|
-
+
|
@item.CodInt
|
-
+ |
@item.Descr
|
diff --git a/StockMan.CORE/Components/ItemList.razor.cs b/StockMan.CORE/Components/ItemList.razor.cs
index 6d84249..2231e5c 100644
--- a/StockMan.CORE/Components/ItemList.razor.cs
+++ b/StockMan.CORE/Components/ItemList.razor.cs
@@ -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;
+ }
+ }
+ }
}
\ No newline at end of file
diff --git a/StockMan.CORE/Data/StockDataService.cs b/StockMan.CORE/Data/StockDataService.cs
index 560309e..c10c34c 100644
--- a/StockMan.CORE/Data/StockDataService.cs
+++ b/StockMan.CORE/Data/StockDataService.cs
@@ -275,40 +275,81 @@ namespace StockMan.CORE.Data
Log.Debug($"ItemsGetAll | {source} in: {ts.TotalMilliseconds} ms");
return dbResult;
}
+
+ /////
+ ///// Lista Articoli da ricerca
+ /////
+ /////
+ //public async Task> ItemsGetSearch(string searchVal, string famID)
+ //{
+ // string source = "DB";
+ // List? dbResult = new List();
+ // 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>(rawData);
+ // if (tempResult == null)
+ // {
+ // dbResult = new List();
+ // }
+ // 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();
+ // }
+ // stopWatch.Stop();
+ // TimeSpan ts = stopWatch.Elapsed;
+ // Log.Debug($"ItemsGetSearch | {source} in: {ts.TotalMilliseconds} ms");
+ // return dbResult;
+ //}
///
/// Lista Articoli da ricerca
///
///
- public async Task> ItemsGetSearch(string searchVal, string famID)
+ public async Task ItemsGetSearch(int id)
{
string source = "DB";
- List? dbResult = new List();
- 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>(rawData);
- if (tempResult == null)
- {
- dbResult = new List();
- }
- else
- {
- dbResult = tempResult;
- }
- }
- else
- {
- dbResult = dbController.ItemsGetSearch(searchVal, famID);
+ //if (!string.IsNullOrEmpty(rawData))
+ //{
+ // source = "REDIS";
+ // var tempResult = JsonConvert.DeserializeObject>(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();
+ dbResult = new ItemModel();
}
stopWatch.Stop();
TimeSpan ts = stopWatch.Elapsed;
diff --git a/StockMan.CORE/Pages/ItemDetail.razor b/StockMan.CORE/Pages/ItemDetail.razor
new file mode 100644
index 0000000..1d70878
--- /dev/null
+++ b/StockMan.CORE/Pages/ItemDetail.razor
@@ -0,0 +1,29 @@
+@page "/ItemDetail"
+
+
+@if (itemToDet != null)
+{
+
+}
diff --git a/StockMan.CORE/Pages/ItemDetail.razor.cs b/StockMan.CORE/Pages/ItemDetail.razor.cs
new file mode 100644
index 0000000..43fad96
--- /dev/null
+++ b/StockMan.CORE/Pages/ItemDetail.razor.cs
@@ -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;
+ }
+}
\ No newline at end of file
diff --git a/StockMan.Data/Controllers/StoManController.cs b/StockMan.Data/Controllers/StoManController.cs
index 87d70a5..5b48404 100644
--- a/StockMan.Data/Controllers/StoManController.cs
+++ b/StockMan.Data/Controllers/StoManController.cs
@@ -236,20 +236,41 @@ namespace StockMan.Data.Controllers
return fatto;
}
+ /////
+ ///// Lista Items da ricerca
+ /////
+ /////
+ //public List ItemsGetSearch(string searchVal, string famID)
+ //{
+ // List dbResult = new List();
+ // 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;
+ //}
///
/// Lista Items da ricerca
///
///
- public List ItemsGetSearch(string searchVal, string famID)
+ public ItemModel ItemsGetSearch(int id)
{
- List dbResult = new List();
+ 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;
}
|