I have two Razor components, AreaLightRebates and DuskToDawnRebates which are pretty similar in functionality. But, since services and models are different, I had to create two almost identical razor components which is a burden as I have to duplicate changes in both the pages everytime.
Wondering, if a single razor component can be used while injecting the models and services dynamically.
AreaLightRebates.razor snippet..
public partial class AreaLightRebates
{
[Inject]
AreaLightRebatesService rebateService { get; set; }
[Inject]
AreaLightTypeService rateService { get; set; }
[Inject]
AreaLightTypeService lightTypeService { get; set; }
[Inject]
PoleTypeService poleTypeService { get; set; }
[Inject]
TaxRateService taxService { get; set; }
[Inject]
InterestRateService interestService { get; set; }
[Inject]
IJSRuntime jSRuntime { get; set; }
private List<AreaLightRebate> lightRebates;
public string selectedItemPlaceholder;
DuskToDawnRebates.razor snippet..
public partial class DuskToDawnRebates
{
[Inject]
DuskToDawnRebateService rebateService { get; set; }
[Inject]
DuskToDawnRatesService rateService { get; set; }
[Inject]
DtdLightTypeService dtdTypeService { get; set; }
[Inject]
PoleTypeService poleTypeService { get; set; }
[Inject]
TaxRateService taxService { get; set; }
[Inject]
InterestRateService interestService { get; set; }
private List<DuskToDawnLightRebate> dtdRebates;
private string selectedItemPlaceholder;
private List<DdlModel> dtdTypesDdl;
As you can see from above, the injected services are different but code after OnInitializedAsync is same for both the razor components respectively. Is it possible to have one page for both the rebates while injecting the services as per the Rebate Type?