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 Create(ServiceTypeModel viewModel)
        {
            if (viewModel == null)
            {
                throw new ArgumentNullException("viewModel");
            }
            ServiceType item = new ServiceType {
                IsActive = true
            };

            viewModel.CopyTo(item);
            if (ServiceTypeRepository.Items.Any(s => s.Name == item.Name && !s.IsActive))
            {
                item          = ServiceTypeRepository.Items.Include("ServiceOfferings.Program.Schools").Single(s => s.Name == item.Name);
                item.IsActive = true;
            }
            else
            {
                ServiceTypeRepository.Add(item);
            }
            UpdateTypeCategories(viewModel.SelectedCategories, item);
            UpdateServiceTypePrograms(viewModel.SelectedPrograms, item);
            RepositoryContainer.Save();
        }
 public void Create(ServiceTypeModel viewModel)
 {
     if (viewModel == null)
     {
         throw new ArgumentNullException("viewModel");
     }
     ServiceType item = new ServiceType { IsActive = true };
     viewModel.CopyTo(item);
     if (ServiceTypeRepository.Items.Any(s => s.Name == item.Name && !s.IsActive))
     {
         item = ServiceTypeRepository.Items.Include("ServiceOfferings.Program.Schools").Single(s => s.Name == item.Name);
         item.IsActive = true;
     }
     else
     {
         ServiceTypeRepository.Add(item);
     }
     UpdateTypeCategories(viewModel.SelectedCategories, item);
     UpdateServiceTypePrograms(viewModel.SelectedPrograms, item);
     RepositoryContainer.Save();
 }
 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();
 }