public void Edit(ServiceTypeModel viewModel)
        {
            var updatedServiceType = ServiceTypeRepository.Items.Include("ServiceOfferings.Program.Schools").Include(s => s.Categories).Include("ServiceOfferings.Program").SingleOrDefault(s => s.Id == viewModel.Id);

            if (updatedServiceType == null)
            {
                throw new EntityNotFoundException("Service Type not found.");
            }
            viewModel.CopyTo(updatedServiceType);
            ServiceTypeRepository.Update(updatedServiceType);
            UpdateTypeCategories(viewModel.SelectedCategories, updatedServiceType);
            UpdateServiceTypePrograms(viewModel.SelectedPrograms, updatedServiceType);
            RepositoryContainer.Save();
        }
        public void SetPrivacy(EducationSecurityPrincipal user, int typeId, bool isPrivate)
        {
            IPermission permission = PermissionFactory.Current.Create("SetServiceTypePrivacy");

            permission.GrantAccess(user);
            ServiceType serviceType = ServiceTypeRepository.Items.SingleOrDefault(s => s.Id == typeId);

            if (serviceType == null)
            {
                throw new EntityNotFoundException("Service Type with the specified ID was not found.");
            }
            serviceType.IsPrivate = isPrivate;
            ServiceTypeRepository.Update(serviceType);
            RepositoryContainer.Save();
        }
예제 #3
0
        public bool UpdateServiceType(ServiceType entity)
        {
            try
            {
                bool bOpDoneSuccessfully;
                using (var repository = new ServiceTypeRepository())
                {
                    bOpDoneSuccessfully = repository.Update(entity);
                }

                return(bOpDoneSuccessfully);
            }
            catch (Exception ex)
            {
                //Log exception error
                _loggingHandler.LogEntry(ExceptionHandler.GetExceptionMessageFormatted(ex), true);

                throw new Exception("BusinessLogic:ServiceTypesBusiness::UpdateServiceType::Error occured.", ex);
            }
        }