Skip to content

Instantly share code, notes, and snippets.

@StevenTCramer
Created February 10, 2016 21:02
Show Gist options
  • Save StevenTCramer/c7dc36a1bcb683835619 to your computer and use it in GitHub Desktop.
Save StevenTCramer/c7dc36a1bcb683835619 to your computer and use it in GitHub Desktop.
public class Command : IRequest
{
private MyDbContext MyDbContext { get; }
public Command(MyDbContext aMyDbContext)
{
MyDbContext = aMyDbContext;
}
public int ProjectId { get; set; }
internal Project Project
{
get
{
return MyDbContext.Projects.Find(ProjectId);
}
}
}
public class CommandValidator : AbstractValidator<Command>
{
public CommandValidator()
{
RuleFor(aCommand => aCommand.ProjectId).NotNull();
RuleFor(aCommand => aCommand.Project).NotNull().WithMessage("Project with Id does not exsit etc....");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment