コード例 #1
0
        public async Task <IActionResult> Post([FromBody] ProjetoFormViewModel model)
        {
            var result = await _projetoService.Cadastrar(_mapper.Map <Projeto>(model));

            if (result.IsValid)
            {
                return(Ok(_mapper.Map <ProjetoViewModel>(result.Entity)));
            }

            return(BadRequest(result.Result));
        }
コード例 #2
0
        public async Task <IActionResult> SetEstado(Guid projetoId, [FromBody] ProjetoFormViewModel model)
        {
            if (!await _projetoService.Existe(projetoId))
            {
                return(RegistroNaoEncontrado(projetoId));
            }

            await _projetoService.AtualizarEstado(projetoId, (int)model.Estado);

            return(Ok());
        }
コード例 #3
0
        public async Task <IActionResult> Put(Guid id, [FromBody] ProjetoFormViewModel model)
        {
            if (!await _projetoService.Existe(id))
            {
                return(RegistroNaoEncontrado(id));
            }

            var result = await _projetoService.Editar(id, _mapper.Map <Projeto>(model));

            if (result.IsValid)
            {
                return(Ok(_mapper.Map <ProjetoViewModel>(result.Entity)));
            }

            return(BadRequest(result.Result));
        }