public static EditCommunityVm GetEditCommunityVm(long id) { if (!CommunityBc.Instance.IsUsersCommunity(id)) { return(null); } Community community = CommunityBc.Instance.GetById(id); EditCommunityVm editCommunityVm = new EditCommunityVm(); editCommunityVm.Id = community.Id; editCommunityVm.MarchexAccountId = community.MarchexAccountId; editCommunityVm.BookId = community.Book.Id; editCommunityVm.Books = AccountBc.Instance.GetBooks().ToSelectListItemList(); editCommunityVm.Package = community.Package; editCommunityVm.ListingTypes = ConverterHelpers.EnumToCheckBoxList(community.ListingTypes); editCommunityVm.SeniorHousingAndCareCategories = ConverterHelpers.DictionaryToCheckBoxList(MSLivingChoices.Bcs.Admin.Components.ItemTypeBc.Instance.GetSHCCategoriesForCommunity(), community.SeniorHousingAndCareCategoryIds); editCommunityVm.AgeRestrictions = ConverterHelpers.EnumToCheckBoxList(community.AgeRestrictions); editCommunityVm.Name = community.Name; editCommunityVm.Address = community.Address.MapToAddressVm(); editCommunityVm.DoNotDisplayAddress = !community.DisplayAddress; editCommunityVm.PhoneList = community.Phones.MapToPhoneListVm(CommunityType.Community); editCommunityVm.PhoneList.AdditionalPhones.ForEach(delegate(PhoneVm ph) { ph.PhoneTypes.RemoveAll((SelectListItem pt) => pt.Text.Contains("Provision")); }); editCommunityVm.EmailList = community.Emails.MapToEmailListVm(CommunityType.Community); List <KeyValuePair <int, string> > contactTypes = MSLivingChoices.Bcs.Admin.Components.ItemTypeBc.Instance.GetContactTypes(CommunityType.Community); editCommunityVm.Contacts = ((community.Contacts != null && community.Contacts.Any()) ? community.Contacts.ConvertAll((Contact m) => GetContactVm(m, contactTypes)) : new List <ContactVm> { GetContactVm(CommunityType.Community) }); editCommunityVm.OfficeHours = ((community.OfficeHours != null && community.OfficeHours.Any()) ? community.OfficeHours.ConvertAll((OfficeHours m) => new OfficeHoursVm(m)) : new List <OfficeHoursVm> { GetOfficeHoursVm() }); editCommunityVm.Description = community.Description; editCommunityVm.WebsiteUrl = community.WebsiteUrl; editCommunityVm.DisplayWebsiteUrl = community.DisplayWebsiteUrl; editCommunityVm.ListingDetails = community.MapToListingDetailsVm(); editCommunityVm.CommunityDetails = community.MapToCommunityDetailsVm(); editCommunityVm.PublishStart = community.Publishing.StartDate; editCommunityVm.PublishEnd = community.Publishing.EndDate; editCommunityVm.ShowcaseStart = community.Showcase.StartDate; editCommunityVm.ShowcaseEnd = community.Showcase.EndDate; return(editCommunityVm); }
public static EditCommunityVm Repopulate(this EditCommunityVm viewModel) { ((NewCommunityVm)viewModel).Repopulate(); return(viewModel); }