@using HR_Taxonomy_Change_Management.Domain
@using HR_Taxonomy_Change_Management.Domain.Model;
@using System.Linq;
@if (!IsEdit)
{
}
@code {
bool LoaderVisible { get; set; } = false;
private string buttonText = string.Empty;
private int wordCount;
private void DoWordCount(string s)
{
wordCount = s.Count();
Request.Justification = s;
}
}
//////////////////from code behind /////////////////////////
///
/// Populates a change ddl based on the parent id of the previous ddl and adds the selection to a ChangeDetailDTO object.
///
///
///
public void GetNextLevel(string parent, int level)
{
string selectedName = string.Empty;
int parentInt = 0;
int.TryParse(parent, out parentInt);
switch (level)
{
case 1:
if (ChangeDetails.NewL1 != parent)
{
L1Value = parent;
if (parentInt != 0)
{
selectedName = L1.Where(x => x.TaxonomyId == parent).Select(x => x.Name).First();
ChangeDetails.NewL1 = !string.IsNullOrEmpty(selectedName) ? selectedName : L1Value;
ChangeDetails.CurrentL1 = !string.IsNullOrEmpty(selectedName) ? selectedName : L1Value;
}
else
{
ChangeDetails.NewL1 = parent;
}
L2Value = L3Value = L4Value = L5Value = string.Empty;
L2 = new List();
L2 = TaxonomyList.Where(x => x.ParentId == parentInt).ToList();
L3 = L4 = L5 = new List();
}
break;
case 2:
if (ChangeDetails.NewL2 != parent)
{
L2Value = parent;
if (parentInt != 0)
{
selectedName = L2.Where(x => x.TaxonomyId == parent).Select(x => x.Name).First();
ChangeDetails.NewL2 = !string.IsNullOrEmpty(selectedName) ? selectedName : L2Value;
ChangeDetails.CurrentL2 = !string.IsNullOrEmpty(selectedName) ? selectedName : L2Value;
}
else
{
ChangeDetails.NewL2 = parent;
ChangeDetails.NewL3 = string.Empty;
ChangeDetails.NewL4 = string.Empty;
ChangeDetails.NewL5 = string.Empty;
}
L3Value = L4Value = L5Value = string.Empty;
L3 = new List();
L3 = TaxonomyList.Where(x => x.ParentId == parentInt).ToList();
L4 = L5 = new List();
}
break;
case 3:
if (ChangeDetails.NewL3 != parent)
{
L3Value = parent;
if (parentInt != 0)
{
selectedName = L3.Where(x => x.TaxonomyId == parent).Select(x => x.Name).First();
ChangeDetails.NewL3 = !string.IsNullOrEmpty(selectedName) ? selectedName : L3Value;
ChangeDetails.CurrentL3 = !string.IsNullOrEmpty(selectedName) ? selectedName : L3Value;
}
else
{
ChangeDetails.NewL3 = parent;
ChangeDetails.NewL4 = string.Empty;
ChangeDetails.NewL5 = string.Empty;
}
L4Value = L5Value = string.Empty;
L4 = new List();
L4 = TaxonomyList.Where(x => x.ParentId == parentInt).ToList();
L5 = new List();
}
break;
case 4:
if (ChangeDetails.NewL4 != parent)
{
L4Value = parent;
if (parentInt != 0)
{
selectedName = L4.Where(x => x.TaxonomyId == parent).Select(x => x.Name).First();
ChangeDetails.NewL4 = !string.IsNullOrEmpty(selectedName) ? selectedName : L4Value;
ChangeDetails.CurrentL4 = !string.IsNullOrEmpty(selectedName) ? selectedName : L4Value;
}
else
{
ChangeDetails.NewL4 = parent;
ChangeDetails.NewL5 = string.Empty;
}
cbl5.Value = string.Empty;
L5 = new List();
L5 = new List();
L5 = TaxonomyList.Where(x => x.ParentId == parentInt).ToList();
}
break;
case 5:
if (ChangeDetails.NewL5 != parent)
{
L5Value = parent;
if (parentInt != 0)
{
selectedName = L5.Where(x => x.TaxonomyId == parent).Select(x => x.Name).First();
ChangeDetails.NewL5 = !string.IsNullOrEmpty(selectedName) ? selectedName : L5Value;
}
else
{
ChangeDetails.NewL5 = parent;
}
}
break;
}
}