public ActionResult ForeignKeyDisplay(string fieldName, int?fieldValue, string primaryTable, bool readOnly) { Type t = Type.GetType("BusinessManager.Business." + primaryTable + "BO, BusinessManager"); List <BaseUIModel> list = null; if (t != null) { object instance = t.GetMethod("GetInstance").Invoke(null, null); object[] parametersArray = new object[] { 0 }; var collection = (IEnumerable)t.GetMethod("GetAll").Invoke(instance, parametersArray); list = new List <BaseUIModel>(); foreach (var item in collection) { list.Add(new BaseUIModel() { ID = Convert.ToInt32(item.GetType().GetProperty("ID").GetValue(item, null)), Name = Convert.ToString(item.GetType().GetProperty("Name").GetValue(item, null)) }); } } ForeignKeyUIModel model = new ForeignKeyUIModel(); model.Value = fieldValue; model.Collection = list; model.Name = fieldName; model.ReadOnly = readOnly; return(View(model)); }
public ActionResult ForeignKeyDisplay(string fieldName, int? fieldValue, string primaryTable, bool readOnly) { Type t = Type.GetType("BusinessManager.Business." + primaryTable + "BO, BusinessManager_Core"); List<BaseUIModel> list = null; if (t != null) { object instance = t.GetMethod("GetInstance").Invoke(null, null); object[] parametersArray = new object[] { 0 }; var collection = (IEnumerable)t.GetMethod("GetAll").Invoke(instance, parametersArray); list = new List<BaseUIModel>(); foreach (var item in collection) { list.Add(new BaseUIModel() { ID = Convert.ToInt32(item.GetType().GetProperty("ID").GetValue(item, null)), Name = Convert.ToString(item.GetType().GetProperty("Name").GetValue(item, null)) }); } } ForeignKeyUIModel model = new ForeignKeyUIModel(); model.Value = fieldValue; model.Collection = list; model.Name = fieldName; model.ReadOnly = readOnly; return View(model); }