Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
public class EmployeeRecognition : IRecognitionHandler
{
public void Recognize(RecognizeRequest request)
{
if (request.GetType() != typeof(EmployeeRecognizeRequest))
{
throw new HandlerException("No handler available for the given request");
}
//do custom logic to remove points from user
}
}
public class ManagerRecognition : IRecognitionHandler
{
private readonly IRecognitionHandler _nextHandler;
public ManagerRecognition(IRecognitionHandler nextHandler)
{
_nextHandler = nextHandler;
}
public void Recognize(RecognizeRequest request)
{
if (request.GetType() != typeof(ManageRecognizeRequest))
{
_nextHandler.Recognize(request);
return;
}
//do custom logic to charge managers account
}
}
public class RecognitionProvider : IRecognitionProvider
{
private readonly IRecognitionHandler _recognitionHandler;
public RecognitionProvider(IRecognitionHandler recognitionHandler)
{
_recognitionHandler = recognitionHandler;
}
public void Recognize(RecognizeRequest request)
{
_recognitionHandler.Recognize(request);
}
}
public class RecognizeRequest
{
public int CompanyId { get; set; }
public int FromId { get; set; }
public int ToId { get; set; }
public string Message { get; set; }
public decimal Amount { get; set; }
}
public class ManagerRecognizeRequest : RecognizeRequest { }
public class EmployeeRecognizeRequest : RecognizeRequest { }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.