Skip to content

Instantly share code, notes, and snippets.

@mgroves
Created March 24, 2014 14:45
Show Gist options
  • Select an option

  • Save mgroves/9741500 to your computer and use it in GitHub Desktop.

Select an option

Save mgroves/9741500 to your computer and use it in GitHub Desktop.
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