Created
October 1, 2013 16:48
-
-
Save jasondentler/6781540 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
namespace Land.Core.Commands | |
{ | |
public interface ICommand { } | |
public class AddContractCommand : ICommand | |
{ | |
public Guid Id { get; set; } | |
public string Name { get; set; } | |
public string ContractTerms { get; set; } | |
} | |
} | |
namespace Land.Business.Contracts | |
{ | |
public interface IHandle<TCommand> where TCommand : ICommand | |
{ | |
void Execute(TCommand command); | |
} | |
public class AddContractHandler : IHandle<AddContractCommand> | |
{ | |
public void Execute(AddContractCommand command) | |
{ | |
throw new NotImplementedException(); | |
} | |
} | |
} | |
namespace Land.UI.Controllers | |
{ | |
public class ContractController : Controller | |
{ | |
[HttpPost, ModelStateToTempData] | |
public RedirectToRouteResult Add(AddContractCommand command) | |
{ | |
if (!ModelState.IsValid) | |
return this.RedirectToRoute(c => c.Add()); | |
_container.Get<IHandle<AddContractCommand>>().Execute(command); | |
return this.RedirectToRoute(c => c.Index(command.Id)); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment