Skip to content

Instantly share code, notes, and snippets.

@jasondentler
Created October 1, 2013 16:48
Show Gist options
  • Save jasondentler/6781540 to your computer and use it in GitHub Desktop.
Save jasondentler/6781540 to your computer and use it in GitHub Desktop.
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