Last active
August 29, 2015 14:25
-
-
Save upnxt/103791b923843fcecf77 to your computer and use it in GitHub Desktop.
This file contains 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 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 | |
} | |
} |
This file contains 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 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 | |
} | |
} |
This file contains 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 class RecognitionProvider : IRecognitionProvider | |
{ | |
private readonly IRecognitionHandler _recognitionHandler; | |
public RecognitionProvider(IRecognitionHandler recognitionHandler) | |
{ | |
_recognitionHandler = recognitionHandler; | |
} | |
public void Recognize(RecognizeRequest request) | |
{ | |
_recognitionHandler.Recognize(request); | |
} | |
} |
This file contains 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 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