Instead of parameterless Action
use generic Action<T>
:
Encapsulates a method that has a single parameter and does not return a value.
Your code should looks like that:
public P Create(Action<P> completed = null)
{
var p = new P();
Insert(p, completed);
return p;
}
public void Insert(P p, Action<P> completed = null)
{
_service.Insert(p,
() =>
{
if (completed != null)
{
completed(p);
}
}
);
}
You have to also change your lambda expression to match Action<P>
:
protected void AddNew()
{
_repo.Create((x) => AddToListItem(x))
}