Skip to content

Instantly share code, notes, and snippets.

@plioi
Created January 26, 2016 22:45
Show Gist options
  • Select an option

  • Save plioi/3feaf52304df5c9aeea1 to your computer and use it in GitHub Desktop.

Select an option

Save plioi/3feaf52304df5c9aeea1 to your computer and use it in GitHub Desktop.
namespace ContactList.Features.Contact
{
using System.Web.Mvc;
using MediatR;
public class ContactController : Controller
{
private readonly IMediator _mediator;
public ContactController(IMediator mediator)
{
_mediator = mediator;
}
//other actions...
public ActionResult Edit(ContactEdit.Query query)
{
var model = _mediator.Send(query);
return View(model);
}
[HttpPost]
public ActionResult Edit(ContactEdit.Command command)
{
if (ModelState.IsValid)
{
_mediator.Send(command);
return RedirectToAction("Index");
}
return View(command);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment