public ProgramModel GenerateDeleteViewModel(int id) { Program program = ProgramRepository.Items.SingleOrDefault(p => p.Id == id); if (program == null) { throw new EntityNotFoundException("Could not find Program with specified Id."); } ProgramModel viewModel = new ProgramModel(); viewModel.CopyFrom(program); return(viewModel); }
public ProgramModel GenerateEditViewModel(int id) { Program program = ProgramRepository.Items.Include(p => p.ServiceOfferings).Include(p => p.Schools).SingleOrDefault(p => p.Id == id); if (program == null || !program.IsActive) { throw new EntityNotFoundException("Could not find Program with specified Id."); } ProgramModel viewModel = new ProgramModel(); viewModel.CopyFrom(program); viewModel.SelectedProviders = program.ServiceOfferings.Where(s => s.IsActive).Select(s => s.ProviderId); viewModel.SelectedServiceTypes = program.ServiceOfferings.Where(s => s.IsActive).Select(s => s.ServiceTypeId); viewModel.SelectedSchools = program.Schools.Select(s => s.Id); return(viewModel); }
public ProgramModel GenerateEditViewModel(int id) { Program program = ProgramRepository.Items.Include(p => p.ServiceOfferings).Include(p => p.Schools).SingleOrDefault(p => p.Id == id); if (program == null || !program.IsActive) { throw new EntityNotFoundException("Could not find Program with specified Id."); } ProgramModel viewModel = new ProgramModel(); viewModel.CopyFrom(program); viewModel.SelectedProviders = program.ServiceOfferings.Where(s => s.IsActive).Select(s => s.ProviderId); viewModel.SelectedServiceTypes = program.ServiceOfferings.Where(s => s.IsActive).Select(s => s.ServiceTypeId); viewModel.SelectedSchools = program.Schools.Select(s => s.Id); return viewModel; }
public ProgramModel GenerateDeleteViewModel(int id) { Program program = ProgramRepository.Items.SingleOrDefault(p => p.Id == id); if (program == null) { throw new EntityNotFoundException("Could not find Program with specified Id."); } ProgramModel viewModel = new ProgramModel(); viewModel.CopyFrom(program); return viewModel; }