public StructuralGroupViewModel UpdateGroup(StructuralGroupViewModel viewModel) { var root = GetRoot(); if (!viewModel.ValidateUpdate(root)) { throw new HttpResponseException(HttpStatusCode.BadRequest); } using (var structureRepository = new StructureRepository(ApplicationContext.DatabaseContext.Database, ApplicationContext.Services.MemberService)) { var targetModel = structureRepository.GetById(viewModel.Id); targetModel.Name = viewModel.Name; targetModel.ParentId = viewModel.ParentId; structureRepository.Update(targetModel); } return(viewModel); }