private object InvokeAction(EntityServiceContext ctx, string methodName) { // Create the appropriate type of actioncontext for the specific entity being managed. // And then set it's errors and messages to the calling context so the errors / messages // can be available to the caller. IActionContext actionContext = EntityRegistration.GetContext(ctx.EntityName); actionContext.CombineMessageErrors = true; actionContext.Item = ctx.Item; actionContext.Id = ctx.Id; actionContext.Errors = ctx.Errors; object service = EntityRegistration.GetService(ctx.EntityName); object result = ReflectionUtils.InvokeMethod(service, methodName, new object[] { actionContext }); return(result); }
/// <summary> /// Delete the specific entity with the id. /// </summary> /// <param name="entityName">"Category"</param> /// <param name="id">"2"</param> public BoolMessage Delete(EntityServiceContext ctx) { object result = InvokeAction(ctx, Settings.DeleteMethod); return(result as BoolMessage); }
private object InvokeAction(Entity entity, string methodName) { var ctx = new EntityServiceContext(entity.GetType(), entity.Id, entity); return(InvokeAction(ctx, methodName)); }
/// <summary> /// Retrieve the entity with the specified id, given the entityType /// </summary> /// <param name="entityName">"Category"</param> /// <param name="id">"1" Id of a specific entity.</param> /// <returns></returns> public BoolMessageItem Get(EntityServiceContext ctx) { object result = InvokeAction(ctx, Settings.RetrieveMethod); return(result as BoolMessageItem); }