public async Task <IHttpActionResult> Put(int id, [FromBody] NationalityViewModel viewModel) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } viewModel.UpdateUser = User.Identity.Name; viewModel.UpdateTime = Now; viewModel.LastAction = "更新"; var model = Mapper.Map <NationalityViewModel, Nationality>(viewModel); _nationalityRepository.AttachAsModified(model); await UnitOfWork.SaveChangesAsync(); return(Ok(viewModel)); }