Last active
March 10, 2019 19:21
-
-
Save anthonydotnet/47360a78423cca6eef0ddebcfc7b0312 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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