Created
March 24, 2014 14:45
-
-
Save mgroves/9741500 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 class TerritoryController : Controller | |
| { | |
| readonly ITerritoryService _terrService; | |
| public TerritoryController(ITerritoryService terrService) | |
| { | |
| _terrService = terrService; | |
| _terrService.AddValidationError = x => ModelState.AddModelError("", x); | |
| } | |
| public ViewResult SomeAction(int? id) | |
| { | |
| // do something with with _terrService | |
| return View(something); | |
| } | |
| } | |
| public class TerritoryService : ITerritoryService | |
| { | |
| public Action<string> AddValidationError { get; set; } | |
| publc int SomeService(int id) | |
| { | |
| // ... | |
| if(theresAnError) | |
| AddValidationError("there was an error"); | |
| // ... | |
| return someInt | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment