Exemple #1
0
        public IActionResult Put(CondominioViewModel vm)
        {
            var model = _mapper.Map <Condominio>(vm);

            try
            {
                _condominioService.Update(model);
                return(NoContent());
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
        public async Task <ActionResult <CondominioViewModel> > Update([FromRoute] Guid id, [FromBody] CondominioViewModel CondominioViewModel)
        {
            if (!ModelState.IsValid)
            {
                return(CustomResponse(ModelState));
            }

            if (id != CondominioViewModel.Id)
            {
                NotifierError("O id informado não é o mesmo que foi passado na query");
                return(CustomResponse(CondominioViewModel));
            }

            if (!ModelState.IsValid)
            {
                return(CustomResponse(ModelState));
            }

            await _dbCondominio.Update(_mapper.Map <Condominio>(CondominioViewModel));

            return(CustomResponse(CondominioViewModel));
        }