Пример #1
0
        public ActionResult <dynamic> Alterar([FromBody] UsuarioViewModel usuarioViewModel)
        {
            try
            {
                ModelValidate();

                var usuarioService = _appUsuarioService.AlterarComValidacao(usuarioViewModel);

                return(Ok(new ResponseViewModel()
                {
                    HttpStatusCode = HttpStatusCode.OK,
                    Data = usuarioService,
                    SuccessMessage = Messaging.MessageSavedSuccess
                }));
            }
            catch (ValidationException vex)
            {
                errors.Add(vex.Message);

                return(StatusCode(HttpStatusCode.BadRequest.ToInt(), new ResponseViewModel()
                {
                    HttpStatusCode = HttpStatusCode.BadRequest,
                    Errors = errors
                }));
            }
            catch (ServiceException servex)
            {
                errors.Clear();
                errors.Add(servex.Message);

                return(StatusCode(HttpStatusCode.OK.ToInt(), new ResponseViewModel()
                {
                    HttpStatusCode = HttpStatusCode.OK,
                    Errors = errors
                }));
            }
            catch (Exception ex)
            {
                errors.Clear();
                errors.Add(ex.Message);

                return(StatusCode(HttpStatusCode.InternalServerError.ToInt(), new ResponseViewModel()
                {
                    HttpStatusCode = HttpStatusCode.InternalServerError,
                    Errors = errors
                }));
            }
        }