예제 #1
0
        public async Task <IActionResult> UpdateUser([FromBody] PersonViewModel personViewModel)
        {
            var dbPerson = await usersProvider.GetPerson(personViewModel.Id);

            if (dbPerson == null)
            {
                return(NotFound("User not found"));
            }
            mapper.Map <PersonViewModel, Person>(personViewModel, dbPerson);
            await usersProvider.UpdatePerson(dbPerson);

            var dbPersonViewModel = mapper.Map <Person, PersonViewModel>(dbPerson);

            return(Ok(dbPersonViewModel));
        }