private void SaveChangesToSicSections(AdminSicSectionUploadCheckViewModel viewModel) { foreach (SicSection sicSectionFromUser in viewModel.AddsEditsDeletesSet.ItemsToAdd) { var sicSection = new SicSection { SicSectionId = sicSectionFromUser.SicSectionId, Description = sicSectionFromUser.Description }; dataRepository.Insert(sicSection); } foreach (OldAndNew <SicSection> oldAndNew in viewModel.AddsEditsDeletesSet.ItemsToChange) { SicSection sicSection = dataRepository.Get <SicSection>(oldAndNew.Old.SicSectionId); sicSection.Description = oldAndNew.New.Description; } foreach (SicSection sicSectionFromUser in viewModel.AddsEditsDeletesSet.ItemsToDelete) { SicSection sicSection = dataRepository.Get <SicSection>(sicSectionFromUser.SicSectionId); dataRepository.Delete(sicSection); } dataRepository.SaveChanges(); }
private static object GetSicSectionDetails(SicSection sicSection) { return(new { sicSection.SicSectionId, sicSection.Description }); }