예제 #1
0
        public async Task <IActionResult> Put(int id, [FromBody] PersonaViewModelActualizar personaViewModel)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }

                if (personaViewModel == null)
                {
                    return(BadRequest());
                }

                if (await PersonaDominio.ObtenerPersonaAsync(id) == null)
                {
                    return(NotFound());
                }

                return(Ok(await PersonaDominio.ActualizarPersonaAsync(id, Mapper.Map <Entidades.Persona>(personaViewModel))));
            }
            catch (DatosInvalidosException ex)
            {
                return(BadRequest(Errores.GetModelStateErrores(ex.Data)));
            }
            catch
            {
                return(StatusCode(500));
            }
        }