Exemple #1
0
        public async Task <IActionResult> Post([FromBody] GrupoFormViewModel model)
        {
            var entity = _mapper.Map <Grupo>(model);

            var result = await _grupoService.Cadastrar(entity);

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

            return(BadRequest(result.Result));
        }
Exemple #2
0
        public async Task <IActionResult> Put(Guid id, [FromBody] GrupoFormViewModel model)
        {
            if (!await _grupoService.Existe(id))
            {
                return(RegistroNaoEncontrado(id));
            }

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

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

            return(BadRequest(result.Result));
        }