public void DeleteGroup(int id) { using (var structureRepository = new StructureRepository(ApplicationContext.DatabaseContext.Database, ApplicationContext.Services.MemberService)) { var model = structureRepository.GetById(id); if (model == null) { throw new HttpResponseException(HttpStatusCode.NotFound); } structureRepository.Delete(model); } }
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); }