public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output) { var contacts = new ContactRepository(); var contact = await contacts.GetAsync(Email); if (contact == null) { output.TagName = null; return; } output.TagName = "div"; output.PreContent.SetContentEncoded("<form>"); var hidden = CreateInputElement("hidden", contact.Id.ToString()); var textBox = CreateInputElement("text", ""); var submit = CreateInputElement("submit", "Send Message"); output.Content.Append(hidden); output.Content.Append(textBox); output.Content.Append(submit); output.PostContent.SetContentEncoded("</form>"); }
public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output) { var contacts = new ContactRepository(); var contact = await contacts.GetAsync(Email); if (contact == null) { output.TagName = null; return; } output.TagName = "form"; output.Content.AppendEncoded($"<input type='hidden' value='{contact.Id}' />"); output.Content.AppendEncoded($"<input type='text' value='' />"); output.Content.AppendEncoded($"<input type='submit' value='Send Message' />"); }