public ActionResult Details(GetUserDetailsQuery query)
{
var model = dispatcher.Query(query);
return Json(model);
}
$.get('@Url.Action("Details","Controller")',callback)
$.get('@Url.Dispatcher().Query(new GetUserDetailsQuery()).AsJson()',callback)
public class DispatcherController : DispatcherControllerBase
{
public DispatcherController()
: base(typeof(T).Assembly)
{ }
}
Query(string incType, string incGeneric, bool? incValidate)
Render(string incView, string incType, string incGeneric)
Push(string incType, string incGeneric)
Composite(string incTypes)
QueryToFile(string incType, string incGeneric, string incContentType, string incFileDownloadName)
Url.Action("Push", "Dispatcher", new { incType = typeof(Command).Name } )
Url.Dispatcher().Push(new Command())
{ success: true/false , data:something/null , redirectTo:url/null }
Url.Dispatcher().Push(new AddUserCommand
{
Id = "59140B31-8BB2-49BA-AE52-368680D5418A",
Name = "Vlad"
})
Url.Dispatcher().Push(new AddEntityCommand<T>())
Url.Dispatcher()
.Push(new AddUserCommand { Id = "1", Name = "Name" })
.Push(new ApproveUserCommand { UserId = "2" })
Url.Dispatcher()
.Query(new GetCurrentDtQuery())
.AsJson()
Url.Dispatcher()
.Query(new GetTypeNameQuery<T>())
.AsJson()
Url.Dispatcher()
.Query(new GetUserQuery())
.AsView("~/Views/Home/User.cshtml")
<a href="@Url.Dispatcher().Query(new GetFileQuery()).AsFile(incFileDownloadName: "framework")">Download</a>
Url.Dispatcher()
.Model(new GetUserQuery.Response
{
Id = "2",
Name = "Incoding Framework"
})
.AsView("~/Views/Home/User.cshtml")
Url.Dispatcher().AsView("~/Views/Home/Template.cshtml")
@(Html.When(JqueryBind.Change)
.AjaxPost(Url.Dispatcher().Push<AddAcoGroupCommand>(new {Value = Selector.Jquery.Self() } ))
.OnSuccess(dsl => dsl.Utilities.Window.Alert("Success"))
.AsHtmlAttributes()
.ToCheckBox(true))
@model AddAcoGroupCommand
<form action="@Url.Dispatcher().Push(new AddAcoGroupCommand())">
@Html.HiddenFor(r=>r.Id)
<input type="submit"/>
</form>
@(Html.When(JqueryBind.InitIncoding)
.AjaxGet(Url.Dispatcher().AsView("~/Views/Patient/BenefitListControl.cshtml"))
.OnSuccess(dsl => dsl.Self().Core().Insert.Html())
.AsHtmlAttributes()
.ToDiv())
var urlTmpl = Url.Dispatcher().AsView("~/Views/Medication/MedicationTmpl.cshtml");
dsl.Self().Core().Insert.WithTemplateByUrl(urlTemplate).Append();
@(Html.When(JqueryBind.InitIncoding)
.AjaxGet(Url.Dispatcher()
.Model( new BenefitModel()
{
GroupName = Selector.Incoding.QueryString<BenefitModel>(r=>r.GroupName),
IsPrimary = true
})
.AsView("~/Views/Patient/BenefitListControl.cshtml"))
.OnSuccess(dsl => dsl.Self().Core().Insert.Html())
.AsHtmlAttributes()
.ToDiv())
@(using(Html.When(JqueryBind.InitIncoding)
.Direct()
.OnSuccess(dsl => dsl.Self().Core().Form.Validation.Parse())
.When(JqueryBind.Submit)
.PreventDefault()
.Submit()
.OnError(dsl => dsl.Self().Core().Form.Validation.Refresh())
.AsHtmlAttributes()
.ToBeginForm(Url.Dispatcher().Push(new AddUserCommand()))))
{
@Html.TextBoxFor(r=>r.Name)
@Html.ValidationMessageFor(r=>r.Name)
}
if (!ModelState.IsValid)
return IncodingResult.Error(ModelState)
try
{
dispatcher.Push(composite);
return IncodingResult.Success();
}
catch (IncWebException exception)
{
foreach (var pairError in exception.Errors)
{
foreach (var errorMessage in pairError.Value)
ModelState.AddModelError(pairError.Key, errorMessage);
}
return IncodingResult.Error(ModelState)
}
public ActionResult Add(AddUserCommand command)
{
if (ModelState.IsValid)
return View(command);
return Execute(command);
}
Break.If(r=>r.Is(()=>Selector.Jquery.Self()).And.Is(()=>"id".ToId()== 12)) // Old
Break.If(()=>Selector.Jquery.Self() && id.ToId() == 12) // New
inDsl.Core().JQuery.Attributes.SetAttr(HtmlAttribute.Checked) // Now
inDsl.Attr.Set(HtmlAttr.Checked) // Future
Source: https://habr.com/ru/post/221585/
All Articles