public ActionResult Delete(BasicEntryForm cty) { Type t = Type.GetType("DynamicformHome.Controllers." + cty.SourceObject); var obj = Activator.CreateInstance(t); //return Ok(); string fName = "Delete"; object[] param = new object[1]; param[0] = cty.IDValue; Type[] paramtypes = new Type[1]; paramtypes[0] = ((int)param[0]).GetType(); MethodInfo voidMethodInfo = t.GetMethod(fName, paramtypes); object ost = voidMethodInfo.Invoke(obj, param); return(Ok()); }
public ActionResult <BasicEntryForm> SaveIem(BasicEntryForm cty) { Type t = Type.GetType("DynamicformHome.Controllers." + cty.SourceObject); var obj = Activator.CreateInstance(t); //return Ok(); foreach (var ptr in obj.GetType() .GetProperties( BindingFlags.Public | BindingFlags.Instance)) { if (ptr.Name.ToLower() == cty.IDColumnName.ToLower()) { ptr.SetValue(obj, cty.IDValue, null); } if (cty.IsNew == false) { if (ptr.Name.ToLower() == "isnew") { ptr.SetValue(obj, false, null); } } if (cty.fromViewType == enumfromViewType.TreeView && cty.IDValue != null) { if (ptr.Name.ToLower() == cty.parentColumnName.ToLower()) { ptr.SetValue(obj, cty.IDValue, null); } } foreach (var item in cty.Controls) { if (ptr.Name.ToLower() == item.PropertyName.ToLower() && ptr.CanWrite) { if (item.controlType == EnumDynamicControlType.TextBox) { ptr.SetValue(obj, item.value, null); } else if (item.controlType == EnumDynamicControlType.DateTime) { ptr.SetValue(obj, Convert.ToDateTime(item.value), null); } else if (item.controlType == EnumDynamicControlType.DropDownEnumData || item.controlType == EnumDynamicControlType.DropDownServerData) { ptr.SetValue(obj, Convert.ToInt32(item.value), null); } else if (item.controlType == EnumDynamicControlType.CheckBox) { if (item.value == "1") { ptr.SetValue(obj, true, null); } else { ptr.SetValue(obj, false, null); } } } //ptr.SetValue(obj, item.value, null); } } MethodInfo voidMethodInfo = t.GetMethod("Save"); voidMethodInfo.Invoke(obj, null); return(CreatedAtAction("", obj)); }