public CreateContatoCommandTests() { _mocker = new AutoMoqer(); _entity = new Contato { canal = _str, nome = _str, valor = _str, obs = _str }; _model = new CreateContatoModel(); }
public async Task <IActionResult> Post([FromBody] CreateContatoModel value) { await _createCommand.Execute(value); if (_createCommand.HasNotifications()) { return(BadRequest(_createCommand.GetNotifications())); } return(Created("", "")); }
public bool IsValid(CreateContatoModel model, ICommand command) { if (string.IsNullOrEmpty(model.canal)) { return(true); } if (!model.canal.Equals("Celular") && !model.canal.Equals("E-mail") && !model.canal.Equals("Telefone")) { command.AddNotification(new Notification { key = "canal", value = string.Format("Apenas Celular, E-mail e Telefone são considerados válidos como canal.", model.canal) }); return(false); } return(true); }
public bool IsValid(CreateContatoModel model, ICommand command) { if (string.IsNullOrEmpty(model.canal) || string.IsNullOrEmpty(model.valor)) { return(true); } if (model.canal.Equals("Telefone") || model.canal.Equals("Celular")) { var regex = @"^(([1-9]{1}[0-9]{1}[9]{1}[0-9]{4}[0-9]{4})|([1-9]{1}[0-9]{1}[1-8]{1}[0-9]{3}[0-9]{4}))$"; Match match = Regex.Match(model.valor, regex, RegexOptions.IgnoreCase); if (!match.Success) { command.AddNotification(new Notification { key = "valor", value = string.Format("O valor não corresponde a um {0}", model.canal) }); return(false); } } return(true); }
public bool IsValid(CreateContatoModel model, ICommand command) { if (string.IsNullOrEmpty(model.canal) || string.IsNullOrEmpty(model.valor)) { return(true); } if (model.canal.Equals("E-mail")) { var regex = @"^([\w\.\-]+)@([\w\-]+)((\.(\w){2,3})+)$"; Match match = Regex.Match(model.valor, regex, RegexOptions.IgnoreCase); if (!match.Success) { command.AddNotification(new Notification { key = "valor", value = "O valor informado não corresponde a um E-mail" }); return(false); } } return(true); }
public CheckIfValorIsAnEmailRuleTests() { _rule = new CheckIfValorIsAnEmailRule(); _model = new CreateContatoModel(); _mocker = new AutoMoqer(); }
public CheckIfCanalIsValidRuleTests() { _rule = new CheckIfCanalIsValidRule(); _model = new CreateContatoModel(); _mocker = new AutoMoqer(); }
public CheckIfValorIsAnTelefoneOrCelularRuleTests() { _rule = new CheckIfValorIsAnTelefoneOrCelularRule(); _model = new CreateContatoModel(); _mocker = new AutoMoqer(); }