Exemplo n.º 1
0
        virtual public CommonResponse AddToParent(string type, int parentId, [FromBody] string value)
        {
            CommonResponse response = new CommonResponse();

            Entity entity;

            try
            {
                Type parentType = Type.GetType("BusinessSpecificLogic.EF." + type + ", BusinessSpecificLogic", true);
                entity = JsonConvert.DeserializeObject <Entity>(value);

                MethodInfo method  = _logic.GetType().GetMethod("AddToParent");
                MethodInfo generic = method.MakeGenericMethod(parentType);
                response = (CommonResponse)generic.Invoke(_logic, new object[] { parentId, entity });
                return(response);
            }
            catch (Exception e)
            {
                return(response.Error("ERROR: " + e.ToString()));
            }
        }