public void Setup() { _projetoForCreationViewModel = new ProjetoForCreationViewModel { Id = 1, Nome = "Test" }; }
public async Task <IResult> InserirAsync(ProjetoForCreationViewModel projetoForCreationViewModel) { var cadastrarProjetoCommand = _mapper.Map <CadastrarProjetoCommand>(projetoForCreationViewModel); var projetoHandler = new ProjetoHandler(_mapper, _repository); var result = await projetoHandler.Handler(cadastrarProjetoCommand); return(result); }
public async Task <IResult> Post([FromBody] ProjetoForCreationViewModel projetoForCreationViewModel) { try { if (!ValidadeModel(projetoForCreationViewModel)) { return(ValidationViewModelResult("Não foi possivel cadastrar projeto", projetoForCreationViewModel.Notifications)); } var result = await _projetoService.InserirAsync(projetoForCreationViewModel); return(result); } catch (Exception ex) { _logger.Error(ex, "Falha ao cadastrar projeto."); return(ErrorResult("Falha ao cadastrar projeto")); } }