Skip to content

Instantly share code, notes, and snippets.

<A>
<B @bind-xyzInB = "@_xyzInA"><B>
</A>
@code {
private FipsDetail? _xyzInA { get; set; }
}
<MyFancyReusableBusinessLogic>
<MyOtherComponent />
</MyFancyReusableBusinessLogic>
@jonhilt
jonhilt / MyProject.csproj
Last active January 10, 2022 17:41
Testing out copying mudblazor files for intellisense purposes
<Target Name="CollectMudBlazorStaticAssets" DependsOnTargets="ResolveStaticWebAssetsInputs" AfterTargets="Build" Condition=" '$(Configuration)' == 'Debug' ">
<Copy SourceFiles="%(StaticWebAsset.Identity)" DestinationFolder="wwwroot/temp" Condition="$([System.String]::Copy(%(StaticWebAsset.Identity)).Contains('mudblazor'))" />
</Target>
<div class="rounded-md bg-white p-2 flex shadow">
<div>
<span class="block mb-4">@Text</span>
</div>
@if (!string.IsNullOrEmpty(Initials))
{
<div class="flex-none ml-2 w-8 h-8 rounded-full flex justify-center items-center bg-purple-400">
<span class="text-sm text-white">@Initials</span>
</div>
}
namespace MessagingTestApp.Features.Mesgs
{
public class List
{
public class Query : IRequest<Model>
{
}
public class Model
{
@jonhilt
jonhilt / Index.cshtml
Last active October 7, 2020 10:54
Prerendering Blazor WASM components
@page
@using PracticalAspNet.UI.Client.Pages
@model IndexModel
@{
ViewData["Title"] = "Home page";
}
<div class="text-center">
<script src="_framework/blazor.webassembly.js"></script>
<component type="typeof(Counter)" render-mode="WebAssemblyPrerendered"/>
protected async Task HandleValidSubmit()
{
var response = await Http.PostAsJsonAsync("api/post", Command);
if (response.StatusCode == HttpStatusCode.BadRequest)
{
var result = await response.Content.ReadFromJsonAsync<CommandResult>();
CustomValidator?.DisplayErrors(result.Errors);
}
else
public class CommandValidator : AbstractValidator<Command>
{
private ApplicationDbContext _dbContext;
public CommandValidator(ApplicationDbContext dbContext)
{
_dbContext = dbContext;
RuleFor(c => c.Body).NotEmpty();
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Net.Mail;
using System.Threading.Tasks;
using Dapper;
using Donatello.Controllers.Api;
using Donatello.Infrastructure;
using Donatello.Models;
public class OrderController : Controller {
// rest of code omitted
public IActionResult ById(string id){
var order = _dataContext.Orders.FirstOrDefault(x=>x.Id == id);
if(order == null) {
order = new Order();
}
return View(order);