Skip to content

Instantly share code, notes, and snippets.

@anthonydotnet
Last active March 10, 2019 19:21
Show Gist options
  • Save anthonydotnet/47360a78423cca6eef0ddebcfc7b0312 to your computer and use it in GitHub Desktop.
Save anthonydotnet/47360a78423cca6eef0ddebcfc7b0312 to your computer and use it in GitHub Desktop.
public void Main()
{
_service.OnCreate_HasConflict += _service_OnCreate_CustomEvent;
var response = _service.Create(model);
if (response is MyCustomResponse<Profile>)
{
// the conflict event was fired and already handled by custom logic
}
}
public class CrudService<TEntity> where TEntity : class
{
public event CreateDelegate<TEntity> OnCreate_MethodStart;
public event CreateDelegate<TEntity> OnCreate_HasConflict;
...
}
ICreateResponse<Profile> _service_OnCreate_CustomEvent(IRepository<Profile> repository, Profile entity, out bool exitMethod)
{
// do something, then return a custom response which involves ending the method
exitMethod = true;
return new MyCustomResponse<Profile>(entity.Id, entity);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment