public static NewServiceProviderVm GetNewServiceProviderVm()
        {
            NewServiceProviderVm newServiceProviderVm = new NewServiceProviderVm()
            {
                Package           = new PackageType?(PackageType.Basic),
                Books             = AccountBc.Instance.GetBooks().ToSelectListItemList(),
                ServiceCategories = ConverterHelpers.DictionaryToCheckBoxList(MSLivingChoices.Bcs.Admin.Components.ItemTypeBc.Instance.GetSHCCategoriesForServiceProvider()),
                AllCounties       = AdminViewModelsProvider.GetCounties(),
                CountiesServed    = new List <County>(),
                Address           = AdminViewModelsProvider.GetAddressVm(),
                PhoneList         = AdminViewModelsProvider.GetPhoneList(ServiceType.ProductsAndServices)
            };

            newServiceProviderVm.PhoneList.AdditionalPhones.ForEach((PhoneVm ph) => ph.PhoneTypes.RemoveAll((SelectListItem pt) => pt.get_Text().Contains("Provision")));
            newServiceProviderVm.EmailList = AdminViewModelsProvider.GetEmailListVm(ServiceType.ProductsAndServices);
            newServiceProviderVm.Contacts  = new List <ContactVm>()
            {
                AdminViewModelsProvider.GetContactVm(ServiceType.ProductsAndServices)
            };
            newServiceProviderVm.OfficeHours = new List <OfficeHoursVm>()
            {
                AdminViewModelsProvider.GetOfficeHoursVm()
            };
            newServiceProviderVm.PaymentTypes       = ConverterHelpers.DictionaryToCheckBoxList(MSLivingChoices.Bcs.Admin.Components.ItemTypeBc.Instance.GetPaymentTypes());
            newServiceProviderVm.Coupon             = new CouponVm();
            newServiceProviderVm.Images             = new ImageListVm(DisplayNames.ServiceProviderImages);
            newServiceProviderVm.CallTrackingPhones = new List <CallTrackingPhoneVm>()
            {
                new CallTrackingPhoneVm()
            };
            return(newServiceProviderVm);
        }
        public static EditServiceProviderVm GetEditServiceProviderVm(long id)
        {
            if (!ServiceProviderBc.Instance.IsUsersService(id))
            {
                return(null);
            }
            ServiceProvider       serviceProvider       = ServiceProviderBc.Instance.GetById(id);
            EditServiceProviderVm editServiceProviderVm = new EditServiceProviderVm()
            {
                Id = serviceProvider.Id,
                MarchexAccountId  = serviceProvider.MarchexAccountId,
                BookId            = serviceProvider.Book.Id,
                Books             = AccountBc.Instance.GetBooks().ToSelectListItemList(),
                ServiceCategories = ConverterHelpers.DictionaryToCheckBoxList(MSLivingChoices.Bcs.Admin.Components.ItemTypeBc.Instance.GetSHCCategoriesForServiceProvider(), (
                                                                                  from sc in serviceProvider.ServiceCategories
                                                                                  select sc.Key).ToList <long>()),
                AllCounties    = AdminViewModelsProvider.GetCounties(),
                CountiesServed = ServiceProviderBc.Instance.GetCountiesServedById(id),
                PhoneList      = serviceProvider.Phones.MapToPhoneListVm(ServiceType.ProductsAndServices)
            };

            editServiceProviderVm.PhoneList.AdditionalPhones.ForEach((PhoneVm ph) => ph.PhoneTypes.RemoveAll((SelectListItem pt) => pt.get_Text().Contains("Provision")));
            editServiceProviderVm.EmailList = serviceProvider.Emails.MapToEmailListVm(ServiceType.ProductsAndServices);
            List <KeyValuePair <int, string> > contactTypes = MSLivingChoices.Bcs.Admin.Components.ItemTypeBc.Instance.GetContactTypes(ServiceType.ProductsAndServices);

            editServiceProviderVm.Contacts = (serviceProvider.Contacts == null || !serviceProvider.Contacts.Any <Contact>() ? new List <ContactVm>()
            {
                AdminViewModelsProvider.GetContactVm(ServiceType.ProductsAndServices)
            } : serviceProvider.Contacts.ConvertAll <ContactVm>((Contact m) => AdminViewModelsProvider.GetContactVm(m, contactTypes)));
            editServiceProviderVm.OfficeHours = (serviceProvider.OfficeHours == null || !serviceProvider.OfficeHours.Any <OfficeHours>() ? new List <OfficeHoursVm>()
            {
                AdminViewModelsProvider.GetOfficeHoursVm()
            } : serviceProvider.OfficeHours.ConvertAll <OfficeHoursVm>((OfficeHours m) => new OfficeHoursVm(m)));
            editServiceProviderVm.FeatureStartDate  = serviceProvider.FeatureStartDate;
            editServiceProviderVm.FeatureEndDate    = serviceProvider.FeatureEndDate;
            editServiceProviderVm.Description       = serviceProvider.Description;
            editServiceProviderVm.WebsiteUrl        = serviceProvider.WebsiteUrl;
            editServiceProviderVm.DisplayWebsiteUrl = serviceProvider.DisplayWebsiteUrl;
            editServiceProviderVm.Name                         = serviceProvider.Name;
            editServiceProviderVm.PublishEndDate               = serviceProvider.PublishEndDate;
            editServiceProviderVm.PublishStartDate             = serviceProvider.PublishStartDate;
            editServiceProviderVm.Package                      = serviceProvider.Package;
            editServiceProviderVm.Address                      = (serviceProvider.Address == null ? AdminViewModelsProvider.GetAddressVm() : serviceProvider.Address.MapToAddressVm());
            editServiceProviderVm.DoNotDisplayAddress          = !serviceProvider.DisplayAddress;
            editServiceProviderVm.PaymentTypes                 = ConverterHelpers.DictionaryToCheckBoxList(MSLivingChoices.Bcs.Admin.Components.ItemTypeBc.Instance.GetPaymentTypes(), serviceProvider.PaymentTypeIds);
            editServiceProviderVm.Images                       = serviceProvider.Images.MapToImageListVm(DisplayNames.ServiceProviderImages);
            editServiceProviderVm.Coupon                       = (serviceProvider.Coupon != null ? serviceProvider.Coupon.MapToCouponVm() : new CouponVm());
            editServiceProviderVm.ProvisionCallTrackingNumbers = serviceProvider.CallTrackingPhones.Any <CallTrackingPhone>();
            editServiceProviderVm.CallTrackingPhones           = AdminViewModelsProvider.GetCallTrackingPhoneVmList(serviceProvider.CallTrackingPhones);
            return(editServiceProviderVm);
        }