public async Task <IActionResult> Create() { int projectId = HttpContext.Request.Cookies.GetProjectId().Value; var model = new TemplateVariableDetailViewModel { ProjectId = projectId, Variables = await Mediator.Send(new GetTemplateVariablesListQuery { ProjectId = projectId }) }; return(View(model)); }
public async Task <IActionResult> Create(TemplateVariableDetailViewModel model) { if (!ModelState.IsValid) { model.Variables = await Mediator.Send(new GetTemplateVariablesListQuery { ProjectId = model.ProjectId }); return(View("create", model) .WithWarning("Info", "Error occured, cannot be saved.")); } await Mediator.Send(new CreateTemplateVariableCommand { ProjectId = model.ProjectId, Label = model.Label, Content = model.Content, ParentTemplateVariableId = model.ParentTemplateVariableId, ShowRaw = model.ShowRaw, Type = model.Type }); return(RedirectToAction("Index") .WithSuccess("Variable", "Created successfully.")); }