This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ValidatorHandler<TRequest, TResponse> | |
: IRequestHandler<TRequest, TResponse> | |
where TRequest : IRequest<TResponse> | |
{ | |
private readonly IRequestHandler<TRequest, TResponse> _inner; | |
private readonly IValidator<TRequest> _validator; | |
public ValidatorHandler(IRequestHandler<TRequest, TResponse> inner, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ImportModelStateFromTempData] | |
public ActionResult Register() | |
{ | |
return View(); | |
} | |
[HttpPost, ValidateAntiForgeryToken, ValidateModelState] | |
public ActionResult Register(RegisterViewModel model) | |
{ | |
var command = _mapper.Map<RegisterCommand>(model); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ImportModelStateFromTempData] | |
public ActionResult Register() | |
{ | |
return View(); | |
} | |
[HttpPost, ValidateAntiForgeryToken, ValidateModelState] | |
public ActionResult Register(RegisterViewModel model) | |
{ | |
var command = _mapper.Map<RegisterCommand>(model); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class RegsiterCommandValidator : IValidator<RegisterCommand> | |
{ | |
private readonly IValidationResult _validationResult; | |
private readonly IDbContext _context; | |
public RegsiterCommandValidator(IValidationResult validationResult, IDbContext context) | |
{ | |
_validationResult = validationResult; | |
_context = context; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class RegisterViewModel | |
{ | |
[Required, Range(3, 50)] | |
public string FirstName { get; set; } | |
[Required, Range(3, 50)] | |
public string LastName { get; set; } | |
[Required, Range(3, 50)] | |
public string UserName { get; set; } | |
[Required, EmailAddress] | |
public string Email { get; set; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ImportModelStateFromTempData] | |
public ActionResult Register() | |
{ | |
return View(); | |
} | |
[HttpPost, ValidateAntiForgeryToken, ValidateModelState] | |
public ActionResult Register(RegisterViewModel model) | |
{ | |
var command = _mapper.Map<RegisterCommand>(model); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class RegsiterCommandValidator : MessageValidator<RegisterCommand> | |
{ | |
private readonly IAfaemsDbContext _context; | |
public RegsiterCommandValidator(IAfaemsDbContext context) | |
{ | |
_context = context; | |
} | |
public override ValidationResult Validate(RegisterCommand command) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public abstract class MessageValidator<IRequest> | |
{ | |
private readonly DataAnnotationsValidator _dataAnnotationsValidator; | |
protected ValidationResult _result; | |
protected MessageValidator() | |
{ | |
_dataAnnotationsValidator = new DataAnnotationsValidator(); | |
_result = new ValidationResult(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class RegisterViewModel | |
{ | |
[Required, StringLength(50)] | |
public string FirstName { get; set; } | |
[Required, StringLength(50)] | |
public string LastName { get; set; } | |
[Required, StringLength(50)] | |
public string UserName { get; set; } | |
[Required, EmailAddress, StringLength(250)] | |
public string Email { get; set; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class RegsiterCommandValidator : MessageValidator<RegisterCommand> | |
{ | |
private readonly IDbContext _context; | |
public RegsiterCommandValidator(IDbContext context) | |
{ | |
_context = context; | |
} | |
public override ValidationResult Validate(RegisterCommand command) |
OlderNewer