Beispiel #1
0
        public ProviderModel GenerateDeleteViewModel(int id)
        {
            var provider = ProviderRepository.Items.SingleOrDefault(p => p.Id == id);

            if (provider == null)
            {
                throw new EntityNotFoundException("Specified Provider does not exist");
            }
            ProviderModel model = new ProviderModel();

            model.CopyFrom(provider);
            return(model);
        }
Beispiel #2
0
        public ProviderModel GenerateEditViewModel(EducationSecurityPrincipal user, int providerId)
        {
            var provider = ProviderRepository.Items.Include("ServiceOfferings.Program").SingleOrDefault(p => p.Id == providerId);

            if (provider == null || !provider.IsActive)
            {
                throw new EntityNotFoundException("Specified Provider does not exist.");
            }
            IPermission permission = PermissionFactory.Current.Create("EditProvider", providerId);

            permission.GrantAccess(user);
            ProviderModel viewModel = new ProviderModel();

            viewModel.CopyFrom(provider);
            viewModel.SelectedPrograms = provider.ServiceOfferings.Select(s => s.Program).Select(p => p.Id);
            PopulateViewModel(viewModel);
            return(viewModel);
        }