Files
mapo-core/MP.SPEC/Components/RecipeMan.razor.cs
T
Samuele Locatelli 1bfee37b4f SPEC:
- Inizio a generare ricetta da template
2023-02-08 10:37:24 +01:00

58 lines
1.7 KiB
C#

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;
namespace MP.SPEC.Components
{
public partial class RecipeMan
{
[Parameter]
public int IdxPODL { get; set; } = 0;
[Parameter]
public string RecipePath { get; set; } = "";
[Inject]
protected MpDataService MDService { get; set; } = null!;
protected RecipeModel? CurrRecipe { get; set; } = null;
protected bool isLoading = false;
protected override async Task OnParametersSetAsync()
{
await Task.Delay(1);
isLoading = true;
if (IdxPODL != 0 && !string.IsNullOrEmpty(RecipePath))
{
CurrRecipe = new RecipeModel();
// effettua ricerca ricetta su MongoDb
CurrRecipe = await MDService.RecipeGetByPODL(IdxPODL);
// se non trova crea nuova...
if (CurrRecipe == null || string.IsNullOrEmpty(CurrRecipe.Id))
{
CurrRecipe = MDService.InitRecipe(IdxPODL, RecipePath);
}
}
await Task.Delay(1);
isLoading = false;
//await InvokeAsync(StateHasChanged);
}
}
}