- OK salvataggio ricetta in MongoDB
This commit is contained in:
Samuele Locatelli
2023-02-08 18:52:38 +01:00
parent c92d8e0096
commit dde39d52dd
10 changed files with 243 additions and 42 deletions
+35 -6
View File
@@ -4,25 +4,54 @@
}
else
{
<div class="card">
<div class="card shadow p-3 mb-5 bg-body rounded">
<div class="card-header">
<h5>Dati Ricetta</h5>
<h5>Testata Ricetta</h5>
@if (CurrRecipe?.HeadVal != null)
{
<div class="row g-1">
@foreach (var item in CurrRecipe.HeadVal)
{
<div class="col-3">
<div class="form-floating">
<input type="text" class="form-control" placeholder="@item.Key" @bind-value="@CurrRecipe.HeadVal[item.Key]">
<label>@item.Key</label>
<div class="form-floating2">
<small class="form-label small">@item.Key</small>
@if (item.Value.Type == MP.Data.MgModels.RecipeModel.KeyType.Fixed)
{
<input type="text" class="form-control" placeholder="@item.Key" @bind-value="@item.Value.Value" disabled>
}
else if (item.Value.Type == MP.Data.MgModels.RecipeModel.KeyType.Enum)
{
<select class="form-select" @bind="@item.Value.Value">
@foreach (var enumItem in GetListByType(item.Value.EnumType))
{
<option value="@enumItem.Key">@enumItem.Value</option>
}
</select>
}
else
{
<input type="text" class="form-control" placeholder="@item.Key" @bind-value="@item.Value.Value">
}
</div>
</div>
}
</div>
<div class="row g-1">
<div class="col-6">
<div class="d-grid">
<button class="btn btn-sm btn-success" @onclick="() => SaveHeadData()">Save</button>
</div>
</div>
<div class="col-6">
<div class="d-grid">
<button class="btn btn-sm btn-warning" @onclick="() => CancelHeadData()">Cancel</button>
</div>
</div>
</div>
}
</div>
<div class="card-body">
<h5>Righe Ricetta</h5>
@if (CurrRecipe?.RowsVal != null)
{
@foreach (var riga in CurrRecipe.RowsVal)
@@ -32,7 +61,7 @@ else
{
<div class="col-3">
<div class="form-floating">
<input type="text" class="form-control" placeholder="@item.Key" @bind-value="@CurrRecipe.RowsVal[riga.Key][item.Key]">
<input type="text" class="form-control" placeholder="@item.Key" @bind-value="@item.Value.Value">
<label>@item.Key</label>
</div>
</div>
+56 -19
View File
@@ -1,20 +1,4 @@
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 MP.SPEC;
using MP.SPEC.Shared;
using MP.SPEC.Components;
using EgwCoreLib.Razor;
using MP.Data.MgModels;
using MP.SPEC.Data;
@@ -22,20 +6,72 @@ namespace MP.SPEC.Components
{
public partial class RecipeMan
{
#region Public Properties
[Parameter]
public int IdxPODL { get; set; } = 0;
[Parameter]
public string RecipePath { get; set; } = "";
#endregion Public Properties
#region Protected Fields
protected bool isLoading = false;
#endregion Protected Fields
#region Protected Properties
protected RecipeModel? CurrRecipe { get; set; } = null;
[Inject]
protected MpDataService MDService { get; set; } = null!;
protected RecipeModel? CurrRecipe { get; set; } = null;
#endregion Protected Properties
protected bool isLoading = false;
#region Protected Methods
protected async Task CancelHeadData()
{
await ReloadData();
}
protected Dictionary<string, string> GetListByType(string DictType)
{
Dictionary<string, string> answ = new Dictionary<string, string>();
// inn primis il "selezionare"
answ.Add("", "--- Selezionare ---");
// cerco tipo in enums...
if (CurrRecipe != null && CurrRecipe.HeadConf.EnumVal.ContainsKey(DictType))
{
foreach (var item in CurrRecipe.HeadConf.EnumVal[DictType])
{
answ.Add(item.Key, item.Value);
}
}
return answ;
}
protected override async Task OnParametersSetAsync()
{
await ReloadData();
}
protected async Task SaveHeadData()
{
if (CurrRecipe != null)
{
await MDService.RecipeSetByPODL(CurrRecipe);
}
}
#endregion Protected Methods
#region Private Methods
private async Task ReloadData()
{
await Task.Delay(1);
isLoading = true;
@@ -52,7 +88,8 @@ namespace MP.SPEC.Components
}
await Task.Delay(1);
isLoading = false;
//await InvokeAsync(StateHasChanged);
}
#endregion Private Methods
}
}
+11
View File
@@ -82,6 +82,17 @@ namespace MP.SPEC.Data
return mongoController.InitRecipe(idxPODL, confPath);
}
/// <summary>
/// Salva ricetta su MongoDB
/// </summary>
/// <param name="currRecord"></param>
/// <returns></returns>
public async Task<bool> RecipeSetByPODL(RecipeModel currRecord)
{
bool answ = false;
answ = await mongoController.RecipeSetByPODL(currRecord);
return answ;
}
/// <summary>
/// Ricerca ricetta su MongoDB dato PODL
/// </summary>
/// <param name="idxPODL"></param>
+1 -1
View File
@@ -5,7 +5,7 @@
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<RootNamespace>MP.SPEC</RootNamespace>
<Version>6.16.2302.815</Version>
<Version>6.16.2302.818</Version>
</PropertyGroup>
<ItemGroup>
+1 -1
View File
@@ -1,6 +1,6 @@
<body>
<i>Modulo MAPOSPEC </i>
<h4>Versione: 6.16.2302.815</h4>
<h4>Versione: 6.16.2302.818</h4>
<br /> Note di rilascio:
<ul>
<li>
+1 -1
View File
@@ -1 +1 @@
6.16.2302.815
6.16.2302.818
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>6.16.2302.815</version>
<version>6.16.2302.818</version>
<url>https://nexus.steamware.net/repository/SWS/MP-SPEC/stable/LAST/MP.SPEC.zip</url>
<changelog>https://nexus.steamware.net/repository/SWS/MP-SPEC/stable/LAST/ChangeLog.html</changelog>
<mandatory>false</mandatory>