88 lines
2.4 KiB
C#
88 lines
2.4 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
using Microsoft.JSInterop;
|
|
using Microsoft.AspNetCore.Components;
|
|
using Microsoft.AspNetCore.Components.Web;
|
|
using Radzen;
|
|
using Radzen.Blazor;
|
|
|
|
namespace ILoan.Rules.Web.Components.Pages
|
|
{
|
|
public partial class EditCoreRuleCriterion
|
|
{
|
|
[Inject]
|
|
protected IJSRuntime JSRuntime { get; set; }
|
|
|
|
[Inject]
|
|
protected NavigationManager NavigationManager { get; set; }
|
|
|
|
[Inject]
|
|
protected DialogService DialogService { get; set; }
|
|
|
|
[Inject]
|
|
protected TooltipService TooltipService { get; set; }
|
|
|
|
[Inject]
|
|
protected ContextMenuService ContextMenuService { get; set; }
|
|
|
|
[Inject]
|
|
protected NotificationService NotificationService { get; set; }
|
|
[Inject]
|
|
public RulesService RulesService { get; set; }
|
|
|
|
[Parameter]
|
|
public int ID { get; set; }
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
coreRuleCriterion = await RulesService.GetCoreRuleCriterionById(ID);
|
|
|
|
coreRulesForRuleID = await RulesService.GetCoreRules();
|
|
}
|
|
protected bool errorVisible;
|
|
protected ILoan.Rules.Web.Models.Rules.CoreRuleCriterion coreRuleCriterion;
|
|
|
|
protected IEnumerable<ILoan.Rules.Web.Models.Rules.CoreRule> coreRulesForRuleID;
|
|
|
|
protected async Task FormSubmit()
|
|
{
|
|
try
|
|
{
|
|
await RulesService.UpdateCoreRuleCriterion(ID, coreRuleCriterion);
|
|
DialogService.Close(coreRuleCriterion);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
errorVisible = true;
|
|
}
|
|
}
|
|
|
|
protected async Task CancelButtonClick(MouseEventArgs args)
|
|
{
|
|
DialogService.Close(null);
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool hasRuleIDValue;
|
|
|
|
[Parameter]
|
|
public int? RuleID { get; set; }
|
|
public override async Task SetParametersAsync(ParameterView parameters)
|
|
{
|
|
coreRuleCriterion = new ILoan.Rules.Web.Models.Rules.CoreRuleCriterion();
|
|
|
|
hasRuleIDValue = parameters.TryGetValue<int?>("RuleID", out var hasRuleIDResult);
|
|
|
|
if (hasRuleIDValue)
|
|
{
|
|
coreRuleCriterion.RuleID = hasRuleIDResult;
|
|
}
|
|
await base.SetParametersAsync(parameters);
|
|
}
|
|
}
|
|
} |