public StakeholderController(IConfiguration configuration) { stakeholderRepository = new StakeholderRepository(configuration); }
/// <summary> /// return Table By Type of Entity /// </summary> /// <param name="TName"></param> /// <returns></returns> internal async static Task <List <Options> > GetParametersOptions(string TableName, bool isDeleted = true) { //Expression<Func<, bool>> where = (x => x.isDeleted); List <Options> Options = null; try { if (TableName == typeof(Characteristic).Name) { using (ICharacteristicRepository db = new CharacteristicRepository()) { if (isDeleted == true) { Options = await db.GetOptions(o => new Options() { DisplayText = o.Name, Value = o.CharacteristicID }); } Options = await db.GetOptions(o => new Options() { DisplayText = o.Name, Value = o.CharacteristicID }, (x => !x.IsDeleted)); } } else if (TableName == typeof(FamilyProduct).Name) { using (IFamilyProductRepository db = new FamilyProductRepository()) { if (isDeleted == true) { Options = await db.GetOptions(o => new Options() { DisplayText = o.Name, Value = o.FamilyProductID }); } Options = await db.GetOptions(o => new Options() { DisplayText = o.Name, Value = o.FamilyProductID }, (x => !x.IsDeleted)); } } else if (TableName == typeof(Product).Name) { using (IProductRepository db = new ProductRepository()) { if (isDeleted == true) { Options = await db.GetOptions(o => new Options() { DisplayText = o.Name, Value = o.ProductID }); } Options = await db.GetOptions(o => new Options() { DisplayText = o.Name, Value = o.ProductID }, (x => !x.IsDeleted)); } } else if (TableName == typeof(Stakeholder).Name) { using (IStakeholderRepository db = new StakeholderRepository()) { if (isDeleted == true) { Options = await db.GetOptions(o => new Options() { DisplayText = o.Name, Value = o.StakeholderID }); } Options = await db.GetOptions(o => new Options() { DisplayText = o.Name, Value = o.StakeholderID }, (x => !x.IsDeleted)); } } else if (TableName == typeof(Area).Name) { using (IAreaRepository db = new AreaRepository()) { if (isDeleted == true) { Options = await db.GetOptions(o => new Options() { DisplayText = o.Name, Value = o.AreaID }); } Options = await db.GetOptions(o => new Options() { DisplayText = o.Name, Value = o.AreaID }, (x => !x.IsDeleted)); } } } catch (Exception ex) { Errors.Write(ex); } return(Options); }