Skip to content

Instantly share code, notes, and snippets.

@cbcwebdev
Created October 7, 2011 18:15
Show Gist options
  • Save cbcwebdev/1270989 to your computer and use it in GitHub Desktop.
Save cbcwebdev/1270989 to your computer and use it in GitHub Desktop.
<section class="grid_8">
@using (Html.BeginForm("create", "promotion", FormMethod.Post, new { @class = "form" }))
{
<fieldset>
<p>
@Html.LabelFor(x => x.Title)
@Html.TextBoxFor(x => x.Title, new { @class = "liquid" })
@Html.ValidationMessageFor(x => x.Title)
</p>
<p>
@Html.LabelFor(x => x.Content)
@Html.TextAreaFor(x => x.Content, new { @class = "wysiwyg" })
@Html.ValidationMessageFor(x => x.Content)
</p>
<p>
<button class="green" type="submit">Create Promotion</button>
</p>
</fieldset>
}
</section>
[Serializable]
public class CreatePromotionViewModel
{
[Required]
public string Title
{
get;
set;
}
[Required]
[AllowHtml]
public string Content
{
get;
set;
}
}
public class PromotionController : Controller
{
private readonly IEndpoint _serviceBus;
public PromotionController(IEndpoint serviceBus)
{
_serviceBus = serviceBus;
}
[HttpPost]
public ActionResult Create(CreatePromotionViewModel viewModel)
{
if(ModelState.IsValid)
{
_serviceBus.Send(viewModel);
return RedirectToAction("create.success");
}
return View(viewModel);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment