Created
January 26, 2016 22:45
-
-
Save plioi/3feaf52304df5c9aeea1 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 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