private bool ModelIsValid(CreateContatoModel model) { try { var result = true; if (!this.ModelValidate(model)) { result = false; } if (result) { foreach (var rule in _rules) { if (!rule.IsValid(model, this)) { result = false; } } } return(result); } catch (Exception ex) { throw ex; } }
public async Task Execute(CreateContatoModel model) { if (!this.ModelIsValid(model)) { return; } var contato = _modelFactory.Create(model.nome, model.canal, model.valor, model.obs); await _repository.Add(contato); }