public static List <SelectListItem> GetEditableAmenities() { List <SelectListItem> selectListItems = new List <SelectListItem>(); selectListItems.AddRange(ConverterHelpers.EnumToKoSelectListItems <AmenityType>()); return(selectListItems); }
internal static CommunityForGridVm MapToCommunityForGridVm(this Community community) { string name; CommunityForGridVm communityForGridVm = new CommunityForGridVm(); List <KeyValuePair <int, string> > seniorHousingAndCareCategories = ItemTypeBc.Instance.GetSHCCategoriesForCommunity(); communityForGridVm.Id = community.Id; communityForGridVm.Name = community.Name; communityForGridVm.BookNumber = community.Book.Number; communityForGridVm.CreateUser = community.CreateUserId; if (community.Package.HasValue) { name = Enum.GetName(typeof(PackageType), community.Package); } else { name = null; } communityForGridVm.Package = name; communityForGridVm.Packages = new List <string>(Enum.GetNames(typeof(PackageType))); communityForGridVm.ActiveAdultCommunities = community.ListingTypes.Any <ListingType>((ListingType m) => m == ListingType.ActiveAdultCommunities); communityForGridVm.ActiveAdultHomes = community.ListingTypes.Any <ListingType>((ListingType m) => m == ListingType.ActiveAdultHomes); communityForGridVm.SeniorHousingAndCare = (!community.ListingTypes.Any <ListingType>((ListingType m) => m == ListingType.SeniorHousingAndCare) || community.SeniorHousingAndCareCategoryIds == null ? false : community.SeniorHousingAndCareCategoryIds.Any <long>()); communityForGridVm.SeniorHousingAndCareCategories = ConverterHelpers.DictionaryToCheckBoxList(seniorHousingAndCareCategories, community.SeniorHousingAndCareCategoryIds); communityForGridVm.ShowcaseStartDate = community.Showcase.StartDate; communityForGridVm.ShowcaseEndDate = community.Showcase.EndDate; communityForGridVm.PublishStartDate = community.Publishing.StartDate; communityForGridVm.PublishEndDate = community.Publishing.EndDate; return(communityForGridVm); }
public static NewCommunityVm GetNewCommunityVm() { NewCommunityVm newCommunityVm = new NewCommunityVm() { Books = AccountBc.Instance.GetBooks().ToSelectListItemList(), ListingTypes = ConverterHelpers.EnumToCheckBoxList <ListingType>(), SeniorHousingAndCareCategories = ConverterHelpers.DictionaryToCheckBoxList(MSLivingChoices.Bcs.Admin.Components.ItemTypeBc.Instance.GetSHCCategoriesForCommunity()), AgeRestrictions = ConverterHelpers.EnumToCheckBoxList <AgeRestriction>(), Address = AdminViewModelsProvider.GetAddressVm(), PhoneList = AdminViewModelsProvider.GetPhoneList(CommunityType.Community) }; newCommunityVm.PhoneList.AdditionalPhones.ForEach((PhoneVm ph) => ph.PhoneTypes.RemoveAll((SelectListItem pt) => pt.get_Text().Contains("Provision"))); newCommunityVm.EmailList = AdminViewModelsProvider.GetEmailListVm(CommunityType.Community); newCommunityVm.Contacts = new List <ContactVm>() { AdminViewModelsProvider.GetContactVm(CommunityType.Community) }; newCommunityVm.OfficeHours = new List <OfficeHoursVm>() { AdminViewModelsProvider.GetOfficeHoursVm() }; newCommunityVm.CommunityDetails = AdminViewModelsProvider.GetCommunityDetailsVm(); newCommunityVm.ListingDetails = AdminViewModelsProvider.GetListingDetailsVm(); return(newCommunityVm); }
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 void SetParameter(InventorDocument document, string paramName, string value) { var parameter = document.Parameters.FirstOrDefault(x => x.Name == paramName); if (parameter == null) { LogManager.Add($"Could not find parameter {paramName} in {document.Name}"); return; } switch (parameter.UnitType) { case UnitTypes.Length: case UnitTypes.Angular: parameter.Value = UnitManager.UnitsToInventor(ConverterHelpers.ConvertDouble(value), parameter.UnitType); break; case UnitTypes.Unitless: parameter.Value = ConverterHelpers.ConvertInt(value); break; case UnitTypes.Text: parameter.Value = value; break; } }
internal static ServiceProviderForGridVm MapToServiceProviderForGridVm(this ServiceProvider serviceProvider) { string name; ServiceProviderForGridVm serviceProviderForGridVm = new ServiceProviderForGridVm(); List <KeyValuePair <int, string> > seniorHousingAndCareCategories = ItemTypeBc.Instance.GetSHCCategoriesForServiceProvider(); serviceProviderForGridVm.Id = serviceProvider.Id; serviceProviderForGridVm.Name = serviceProvider.Name; if (serviceProvider.Package.HasValue) { name = Enum.GetName(typeof(PackageType), serviceProvider.Package); } else { name = null; } serviceProviderForGridVm.Package = name; serviceProviderForGridVm.Packages = new List <string>(Enum.GetNames(typeof(PackageType))); serviceProviderForGridVm.SeniorHousingAndCareCategories = ConverterHelpers.DictionaryToCheckBoxList(seniorHousingAndCareCategories, ( from sc in serviceProvider.ServiceCategories select sc.Key).ToList <long>()); serviceProviderForGridVm.FeatureStartDate = serviceProvider.FeatureStartDate; serviceProviderForGridVm.FeatureEndDate = serviceProvider.FeatureEndDate; serviceProviderForGridVm.PublishStartDate = serviceProvider.PublishStartDate; serviceProviderForGridVm.PublishEndDate = serviceProvider.PublishEndDate; return(serviceProviderForGridVm); }
public NSString GetListViewPageDataAsBase64String(NSString noValue) { var listPageData = App.GetListPageData(); var listPageDataAsBase64String = ConverterHelpers.ConvertSerializableObjectToBase64String(listPageData); return(new NSString(listPageDataAsBase64String)); }
public static EditServiceProviderVm Repopulate(this EditServiceProviderVm model) { model.PhoneList = model.PhoneList.Repopulate(ServiceType.ProductsAndServices); model.EmailList = model.EmailList.Repopulate(ServiceType.ProductsAndServices); model.Contacts = model.Contacts.Repopulate(ServiceType.ProductsAndServices); model.PaymentTypes = ConverterHelpers.DictionaryToCheckBoxList(MSLivingChoices.Bcs.Admin.Components.ItemTypeBc.Instance.GetPaymentTypes()); return(model); }
public string GetListViewPageDataAsBase64String() { var listPageData = App.GetListPageData(); var listPageDataAsBase64String = ConverterHelpers.ConvertSerializableObjectToBase64String(listPageData); return(listPageDataAsBase64String); }
public static NewServiceProviderVm Repopulate(this NewServiceProviderVm model) { model.PhoneList = model.PhoneList.Repopulate(ServiceType.ProductsAndServices); model.PhoneList.AdditionalPhones.ForEach((PhoneVm ph) => ph.PhoneTypes.RemoveAll((SelectListItem pt) => pt.get_Text().Contains("Provision"))); model.EmailList = model.EmailList.Repopulate(ServiceType.ProductsAndServices); model.Contacts = model.Contacts.Repopulate(ServiceType.ProductsAndServices); model.PaymentTypes = ConverterHelpers.DictionaryToCheckBoxList(MSLivingChoices.Bcs.Admin.Components.ItemTypeBc.Instance.GetPaymentTypes()); return(model); }
public static CommunityDetailsVm GetCommunityDetailsVm() { CommunityDetailsVm communityDetailsVm = new CommunityDetailsVm() { PaymentTypes = ConverterHelpers.DictionaryToCheckBoxList(MSLivingChoices.Bcs.Admin.Components.ItemTypeBc.Instance.GetPaymentTypes()), PriceRange = new MeasureBoundaryVm <decimal, MoneyType>(), Deposit = new MeasureBoundaryVm <decimal, MoneyType>(), ApplicationFee = new MeasureBoundaryVm <decimal, MoneyType>(), PetDeposit = new MeasureBoundaryVm <decimal, MoneyType>(), LivingSpace = new MeasureBoundaryVm <int, LivingSpaceMeasure>(), AvailableBedroomsFromQuantity = MSLivingChoices.Bcs.Components.ItemTypeBc.Instance.GetBedrooms().ToSelectListItemList(), AvailableBedroomsToQuantity = communityDetailsVm.AvailableBedroomsFromQuantity, AvailableBathroomsFromQuantity = MSLivingChoices.Bcs.Components.ItemTypeBc.Instance.GetBathrooms().ToSelectListItemList(), AvailableBathroomsToQuantity = communityDetailsVm.AvailableBathroomsFromQuantity, DefaultAmenities = AmenityBc.Instance.GetDefaultAmenities(CommunityType.Community).ConvertAll <CheckBoxVm>((Amenity m) => new CheckBoxVm() { Value = m.ClassId.ToString(), Text = m.Name }), CustomAmenities = new List <AmenityVm>() { new AmenityVm() }, DefaultCommunityServices = CommunityServiceBc.Instance.GetDefaultCommunityServices().ConvertAll <CheckBoxVm>((CommunityService m) => new CheckBoxVm() { Value = m.AdditionInfoTypeId.ToString(), Text = m.Name }), CustomCommunityServices = new List <CommunityServiceVm>() { new CommunityServiceVm(), new CommunityServiceVm() } }; communityDetailsVm.CustomCommunityServices = new List <CommunityServiceVm>() { new CommunityServiceVm() }; communityDetailsVm.Coupon = new CouponVm(); communityDetailsVm.FloorPlans = new List <FloorPlanVm>() { AdminViewModelsProvider.GetCommunityUnit(CommunityUnitType.FloorPlan) }; communityDetailsVm.SpecHomes = new List <SpecHomeVm>() { AdminViewModelsProvider.GetCommunityUnit(CommunityUnitType.SpecHome) }; communityDetailsVm.Houses = new List <HouseVm>() { AdminViewModelsProvider.GetHouseUnit() }; communityDetailsVm.Images = new ImageListVm(DisplayNames.CommunityImages); communityDetailsVm.LogoImages = new ImageListVm(DisplayNames.CommunityLogo); return(communityDetailsVm); }
public void SelectVenues(string judgeNames) { _browsers[_c.CurrentUser].Driver.WaitUntilVisible(VhoVenueAllocationPage.VenuesDropdown).Displayed.Should().BeTrue(); _browsers[_c.CurrentUser].Click(VhoVenueAllocationPage.VenuesTextBox); foreach (var venue in ConverterHelpers.ConvertStringIntoArray(judgeNames)) { _browsers[_c.CurrentUser].Driver.WaitUntilVisible(VhoVenueAllocationPage.VenuesTextBox).SendKeys(venue); _browsers[_c.CurrentUser].ClickCheckbox(VhoVenueAllocationPage.VenueCheckbox(venue), 5); } }
public override DimensionCodec?Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { if (reader.TokenType != JsonTokenType.StartObject) { throw new JsonException($"Expected StartObject got: {reader.TokenType}"); } var dimensionCodec = new DimensionCodec(); var props = typeToConvert.GetProperties(); while (reader.Read()) { if (reader.TokenType == JsonTokenType.EndObject) { return(dimensionCodec); } if (reader.TokenType != JsonTokenType.PropertyName) { throw new JsonException($"Expected property name got: {reader.TokenType}"); } var propName = reader.GetString(); reader.Read(); if (string.IsNullOrWhiteSpace(propName)) { throw new JsonException("Property name was null."); } foreach (var(name, property) in this.propertyMap) { var convertedName = options.PropertyNamingPolicy?.ConvertName(name) ?? name; if (!propName.Equals(convertedName, StringComparison.OrdinalIgnoreCase)) { continue; } if (!ConverterHelpers.TryGetAction(property.PropertyType, out var action)) { dimensionCodec.Element = JsonSerializer.Deserialize <DimensionElement>(ref reader, options); continue; } action.Invoke(dimensionCodec, ref reader, property); } } throw new JsonException($"Expected EndObject got: {reader.TokenType}"); }
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); }
internal static FilterForServiceProviderGridVm MapToFilterForServiceProviderGridVm(this ServiceProviderGridFilter filter) { return(new FilterForServiceProviderGridVm() { ServiceProvider = filter.ServiceProvider, Feature = filter.Feature, FeatureStart = filter.FeatureStart, FeatureEnd = filter.FeatureEnd, Publish = filter.Publish, PublishStart = filter.PublishStart, PublishEnd = filter.PublishEnd, Packages = ConverterHelpers.DictionaryToCheckBoxList(ItemTypeBc.Instance.GetAdditionalInfo(AdditionalInfoClass.Package), filter.Packages.ConvertAll <long>((KeyValuePair <int, string> x) => (long)x.Key)), Categories = ConverterHelpers.DictionaryToCheckBoxList(ItemTypeBc.Instance.GetSHCCategoriesForServiceProvider(), filter.Categories.ConvertAll <long>((KeyValuePair <int, string> x) => (long)x.Key)) }); }
internal static List <ListPageDataModel> GetListPageData(IApp app) { string listPageDataAsBase64String; if (app is iOSApp) { listPageDataAsBase64String = app.Invoke("getListViewPageDataAsBase64String:", "").ToString(); } else { listPageDataAsBase64String = app.Invoke("GetListViewPageDataAsBase64String").ToString(); } return(ConverterHelpers.DeserializeObject <List <ListPageDataModel> >(listPageDataAsBase64String)); }
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); }
internal static FilterForCommunityGridVm MapToFilterForCommunityGridVm(this CommunityGridFilter filter) { return(new FilterForCommunityGridVm() { AAC = filter.AAC, AAH = filter.AAH, Community = filter.Community, Packages = ConverterHelpers.DictionaryToCheckBoxList(ItemTypeBc.Instance.GetAdditionalInfo(AdditionalInfoClass.Package), filter.Packages.ConvertAll <long>((KeyValuePair <int, string> x) => (long)x.Key)), Publish = filter.Publish, PublishEnd = filter.PublishEnd, PublishStart = filter.PublishStart, SHC = filter.SHC, Showcase = filter.Showcase, ShowcaseStart = filter.ShowcaseStart, ShowcaseEnd = filter.ShowcaseEnd, SHCCategories = ConverterHelpers.DictionaryToCheckBoxList(ItemTypeBc.Instance.GetSHCCategoriesForCommunity(), filter.Categories.ConvertAll <long>((KeyValuePair <int, string> x) => (long)x.Key)) }); }
public async Task Render(HttpRequest request, HttpResponse response, APEntity toRender) { response.ContentType = ConverterHelpers.GetBestMatch(_factory.MimeTypes, request.Headers["Accept"]); if (toRender.Type.Contains("Tombstone")) { response.StatusCode = 410; } if (request.Method == "POST") { response.StatusCode = 201; response.Headers.Add("Location", toRender.Id); } var depth = Math.Min(int.Parse(request.Query["depth"].FirstOrDefault() ?? "3"), 5); var unflattened = await _flattener.Unflatten(_entityStore, toRender, depth, isOwner : toRender.IsOwner); await response.WriteAsync(unflattened.Serialize(true).ToString()); }
internal static List <ListPageDataModel> GetListPageData(IApp app) { string listPageDataAsBase64String; switch (app) { case iOSApp iosApp: listPageDataAsBase64String = iosApp.Invoke("getSerializedListViewPageData:", "").ToString(); break; case AndroidApp androidApp: listPageDataAsBase64String = androidApp.Invoke("GetSerializedListViewPageData").ToString(); break; default: throw new NotSupportedException("Platform Not Supported"); } return(ConverterHelpers.DeserializeObject <List <ListPageDataModel> >(listPageDataAsBase64String)); }
public async Task Invoke(HttpContext context, IServiceProvider serviceProvider, EntityData entityData, IEntityStore store) { var handler = ActivatorUtilities.CreateInstance <GetEntityHandler>(serviceProvider, context.User); if (entityData.RewriteRequestScheme) { context.Request.Scheme = "https"; } var fullpath = $"{context.Request.Scheme}://{context.Request.Host}{context.Request.Path}"; foreach (var converterFactory in _converters) { if (converterFactory.FileExtension != null && fullpath.EndsWith("." + converterFactory.FileExtension)) { fullpath = fullpath.Substring(0, fullpath.Length - 1 - converterFactory.FileExtension.Length); context.Request.Headers.Remove("Accept"); context.Request.Headers.Add("Accept", converterFactory.RenderMimeType); break; } } /* && ConverterHelpers.GetBestMatch(_converters[0].MimeTypes, context.Request.Headers["Accept"]) != null */ if (context.Request.Method == "OPTIONS") { context.Response.StatusCode = 200; context.Response.Headers.Add("Access-Control-Allow-Credentials", "true"); context.Response.Headers.Add("Access-Control-Allow-Headers", "Authorization"); context.Response.Headers.Add("Access-Control-Allow-Methods", "GET, POST"); context.Response.Headers.Add("Access-Control-Allow-Origin", context.Request.Headers["Origin"]); context.Response.Headers.Add("Vary", "Origin"); return; } Console.WriteLine(fullpath); foreach (var line in context.Request.Headers["Accept"]) { Console.WriteLine($"---- {line}"); } if (context.Request.Headers["Accept"].Contains("text/event-stream")) { await handler.EventStream(context, fullpath); return; } if (context.WebSockets.IsWebSocketRequest) { await handler.WebSocket(context, fullpath); return; } if (context.Request.Method == "POST" && context.Request.ContentType.StartsWith("multipart/form-data")) { context.Items.Add("fullPath", fullpath); context.Request.Path = "/settings/uploadMedia"; await _next(context); return; } if (context.Request.QueryString.Value == "?hub") { context.Items.Add("fullPath", fullpath); context.Request.Path = "/.well-known/hub"; context.Request.QueryString = QueryString.Empty; await _next(context); return; } IConverter readConverter = null; IConverter writeConverter = null; bool needRead = context.Request.Method == "POST"; var target = fullpath; APEntity targetEntity = null; targetEntity = await store.GetEntity(target, false); if (needRead) { if (targetEntity?.Type == "_inbox") { target = (string)targetEntity.Data["attributedTo"].Single().Primitive; } } if (targetEntity == null) { await _next(context); return; } foreach (var converterFactory in _converters) { bool worksForWrite = converterFactory.CanRender && ConverterHelpers.GetBestMatch(converterFactory.MimeTypes, context.Request.Headers["Accept"]) != null; bool worksForRead = needRead && converterFactory.CanParse && ConverterHelpers.GetBestMatch(converterFactory.MimeTypes, context.Request.ContentType) != null; if (worksForRead && worksForWrite && readConverter == null && writeConverter == null) { readConverter = writeConverter = converterFactory.Build(serviceProvider, target); break; } if (worksForRead && readConverter == null) { readConverter = converterFactory.Build(serviceProvider, target); } if (worksForWrite && writeConverter == null) { writeConverter = converterFactory.Build(serviceProvider, target); } } ASObject data = null; if (readConverter != null) { data = await readConverter.Parse(context.Request.Body); } if (needRead && readConverter != null && writeConverter == null) { writeConverter = readConverter; } if (data == null && needRead && targetEntity != null) { context.Response.StatusCode = 415; await context.Response.WriteAsync("Unknown mime type " + context.Request.ContentType); return; } var arguments = context.Request.Query; try { if (context.Request.Method == "GET" || context.Request.Method == "HEAD" || context.Request.Method == "OPTIONS") { data = await handler.Get(fullpath, arguments, context); } else if (context.Request.Method == "POST" && data != null) { data = await handler.Post(context, fullpath, data); } } catch (UnauthorizedAccessException e) { context.Response.StatusCode = 403; await context.Response.WriteAsync(e.Message); } catch (InvalidOperationException e) { context.Response.StatusCode = 401; await context.Response.WriteAsync(e.Message); } if (context.Response.HasStarted) { return; } if (data != null) { if (context.Request.Method == "HEAD") { context.Response.StatusCode = 200; return; } if (writeConverter != null) { await writeConverter.Render(context.Request, context.Response, data); } else if (context.Request.ContentType == "application/magic-envelope+xml") { context.Response.StatusCode = 202; await context.Response.WriteAsync("accepted"); } else { context.Request.Method = "GET"; context.Request.Path = "/render"; context.Items["object"] = APEntity.From(data); await _next(context); } return; } if (!context.Response.HasStarted) { await _next(context); } }
public virtual ServiceProvider ToEntity() { long id; ServiceProvider serviceProvider = new ServiceProvider(); List <long> paymentTypeIds = new List <long>(); foreach (CheckBoxVm checkBoxVm in from m in this.PaymentTypes where m.IsChecked select m) { if (!long.TryParse(checkBoxVm.Value, out id)) { continue; } paymentTypeIds.Add(id); } serviceProvider.PaymentTypeIds = paymentTypeIds; serviceProvider.Coupon = this.Coupon.ToEntity(); serviceProvider.Package = this.Package; serviceProvider.Book = new Book() { Id = this.BookId }; serviceProvider.ServiceCategories = ( from key in ConverterHelpers.CheckBoxListToLongArray(this.ServiceCategories) select new KeyValuePair <long, string>(key, string.Empty)).ToList <KeyValuePair <long, string> >(); serviceProvider.AllCounties = this.AllCounties; serviceProvider.CountiesServed = this.CountiesServed; serviceProvider.Name = this.Name; serviceProvider.Address = (this.AddressValidation.ValidationItems == null ? this.Address.ToEntity() : this.AddressValidation.ToEntity()); serviceProvider.DisplayAddress = !this.DoNotDisplayAddress; serviceProvider.Phones = this.PhoneList.ToEntityList(); serviceProvider.Emails = this.EmailList.ToEntity(); serviceProvider.Contacts = this.Contacts.ConvertAll <Contact>((ContactVm m) => m.ToEntity()).Where <Contact>((Contact x) => { if (!string.IsNullOrWhiteSpace(x.FirstName)) { return(true); } return(!string.IsNullOrWhiteSpace(x.LastName)); }).ToList <Contact>(); serviceProvider.OfficeHours = this.OfficeHours.ConvertAll <MSLivingChoices.Entities.Admin.OfficeHours>((OfficeHoursVm m) => m.ToEntity()); serviceProvider.Description = this.Description; serviceProvider.WebsiteUrl = MslcUrlBuilder.NormalizeUri(this.WebsiteUrl); serviceProvider.DisplayWebsiteUrl = this.DisplayWebsiteUrl; serviceProvider.FeatureStartDate = this.FeatureStartDate; serviceProvider.FeatureEndDate = this.FeatureEndDate; serviceProvider.PublishStartDate = this.PublishStartDate; serviceProvider.PublishEndDate = this.PublishEndDate; serviceProvider.Images = (this.Images != null ? this.Images.ToEntity(ImageType.Photo) : new List <Image>()); serviceProvider.CallTrackingPhones = new List <CallTrackingPhone>(); if (this.CallTrackingPhones != null) { if (!this.ProvisionCallTrackingNumbers) { this.CallTrackingPhones.ForEach((CallTrackingPhoneVm c) => c.IsDisconnected = true); } serviceProvider.CallTrackingPhones = ( from p in this.CallTrackingPhones.ConvertAll <CallTrackingPhone>((CallTrackingPhoneVm m) => m.ToEntity()) where !string.IsNullOrEmpty(p.Phone) select p).ToList <CallTrackingPhone>(); } return(serviceProvider); }
protected override void buttonCaptureDims_Click(object sender, EventArgs e) { var dims = SolidworksApplication.ActiveDocument.GetDimensions(); foreach (var d in dims.Dimensions) { this.Dimensions.Add(new DimensionCapture(SolidworksFormatters.RemoveDocumentNameFromDimension(d.Name), ConverterHelpers.Round(d.Value, 16))); } foreach (var f in dims.Features) { this.Features.Add(new FeatureCapture(f.Name, f.FeatureType, f.Suppressed)); } }
internal static CommunityDetailsVm MapToCommunityDetailsVm(this Community community) { CommunityDetailsVm communityDetails = new CommunityDetailsVm() { PaymentTypes = ConverterHelpers.DictionaryToCheckBoxList(MSLivingChoices.Bcs.Admin.Components.ItemTypeBc.Instance.GetPaymentTypes(), community.PaymentTypeIds), PriceRange = community.PriceRange.MapToMeasureBoundaryVm <decimal, MoneyType>(), Deposit = community.Deposit.MapToMeasureBoundaryVm <decimal, MoneyType>(), ApplicationFee = community.ApplicationFee.MapToMeasureBoundaryVm <decimal, MoneyType>(), PetDeposit = community.PetDeposit.MapToMeasureBoundaryVm <decimal, MoneyType>(), LivingSpace = community.LivingSpace.MapToMeasureBoundaryVm <int, LivingSpaceMeasure>(), BathroomFromId = community.BathroomFromId, BathroomToId = community.BathroomToId }; List <KeyValuePair <int, string> > bedrooms = MSLivingChoices.Bcs.Components.ItemTypeBc.Instance.GetBedrooms(); communityDetails.AvailableBedroomsFromQuantity = bedrooms.ToSelectListItemList(community.BedroomFromId); communityDetails.AvailableBedroomsToQuantity = bedrooms.ToSelectListItemList(community.BedroomToId); communityDetails.BedroomFromId = community.BedroomFromId; communityDetails.BedroomToId = community.BedroomToId; List <KeyValuePair <int, string> > bathrooms = MSLivingChoices.Bcs.Components.ItemTypeBc.Instance.GetBathrooms(); communityDetails.AvailableBathroomsFromQuantity = bathrooms.ToSelectListItemList(community.BathroomFromId); communityDetails.AvailableBathroomsToQuantity = bathrooms.ToSelectListItemList(community.BathroomToId); communityDetails.UnitCount = community.UnitCount; List <Amenity> defaultCommunityAmenities = AmenityBc.Instance.GetDefaultAmenities(CommunityType.Community); communityDetails.DefaultAmenities = community.Amenities.MapToCheckBoxVmList(defaultCommunityAmenities); communityDetails.CustomAmenities = community.Amenities.MapToAmenityVmList(defaultCommunityAmenities); List <CommunityService> defaultCommunityServices = CommunityServiceBc.Instance.GetDefaultCommunityServices(); communityDetails.DefaultCommunityServices = CommunityExtentions.GetDefaultCommunityServices(community.CommunityServices, defaultCommunityServices); communityDetails.CustomCommunityServices = CommunityExtentions.GetCustomCommunityServices(community.CommunityServices, defaultCommunityServices); communityDetails.Images = community.Images.MapToImageListVm(DisplayNames.CommunityImages); communityDetails.LogoImages = community.LogoImages.MapToImageListVm(DisplayNames.CommunityLogo); communityDetails.VirtualTour = community.VirtualTour; communityDetails.Coupon = (community.Coupon != null ? community.Coupon.MapToCouponVm() : new CouponVm()); if (community.FloorPlans == null || !community.FloorPlans.Any <FloorPlan>()) { communityDetails.HasFloorPlans = false; communityDetails.FloorPlans = new List <FloorPlanVm>() { AdminViewModelsProvider.GetCommunityUnit(CommunityUnitType.FloorPlan) }; } else { communityDetails.HasFloorPlans = community.FloorPlans.Any <FloorPlan>(); communityDetails.FloorPlans = community.FloorPlans.MapToFloorPlanVmList(); } if (community.SpecHomes == null || !community.SpecHomes.Any <SpecHome>()) { communityDetails.HasSpecHomes = false; communityDetails.SpecHomes = new List <SpecHomeVm>() { AdminViewModelsProvider.GetCommunityUnit(CommunityUnitType.SpecHome) }; } else { communityDetails.HasSpecHomes = community.SpecHomes.Any <SpecHome>(); communityDetails.SpecHomes = community.SpecHomes.MapToSpecHomeVmList(); } if (community.Houses == null || !community.Houses.Any <House>()) { communityDetails.HasHouses = false; communityDetails.Houses = new List <HouseVm>() { AdminViewModelsProvider.GetHouseUnit() }; } else { communityDetails.HasHouses = community.Houses.Any <House>(); communityDetails.Houses = community.Houses.MapToHouseVmList(); } return(communityDetails); }
public async Task <APEntity> GetEntity(string id, bool doRemote) { if (id == "https://www.w3.org/ns/activitystreams#Public") { var aso = new ASObject(); aso.Type.Add("https://www.w3.org/ns/activitystreams#Collection"); aso.Id = "https://www.w3.org/ns/activitystreams#Public"; var ent = APEntity.From(aso); return(ent); } string origin = id; try { var uri = new Uri(id); if (uri.Host == "localhost") { return(await Bypass.GetEntity(id, doRemote)); } origin = uri.GetLeftPart(UriPartial.Authority); } catch (UriFormatException) { /* nom */ } APEntity entity = null; if (Bypass != null) { entity = await Bypass.GetEntity(id, doRemote); } /* if (entity == null) * { * var possibilities = (await _getRE().Query(new RelevantEntitiesService.ContainsAnyStatement("https://www.w3.org/ns/activitystreams#url") { id })).Where(a => Uri.IsWellFormedUriString(a.Id, UriKind.Absolute) && (new Uri(a.Id)).GetLeftPart(UriPartial.Authority) == origin).ToList(); * if (possibilities.Count == 1) entity = possibilities.First(); * }*/ if (entity != null && !entity.IsOwner && entity.Data.Type.Any(_collections.Contains) && doRemote) { entity = null; } if (entity != null || !doRemote) { return(entity); } var htc = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.Get, id); request.Headers.TryAddWithoutValidation("Accept", "application/activity+json; application/ld+json; profile=\"https://www.w3.org/ns/activitystreams\", application/json, text/html"); if (_context != null) { var signatureVerifier = _serviceProvider.GetRequiredService <SignatureVerifier>(); var user = await Bypass.GetEntity(_context.User.FindFirstValue("actor"), false); if (user != null) { var jwt = await signatureVerifier.BuildJWS(user, id); if (jwt != null) { request.Headers.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", jwt); } request.Headers.TryAddWithoutValidation("Signature", await _keyService.BuildHTTPSignature(user.Id, request)); } } HttpResponseMessage response = null; try { response = await htc.SendAsync(request); } catch (TaskCanceledException) { return(null); // timeout } catch (HttpRequestException) { return(null); } ASObject data = null; await response.Content.LoadIntoBufferAsync(); foreach (var converter in ServerConfig.Converters) { if (converter.CanParse && ConverterHelpers.GetBestMatch(converter.MimeTypes, response.Content.Headers.ContentType.ToString()) != null) { try { data = await converter.Build(_serviceProvider, null).Parse(await response.Content.ReadAsStreamAsync()); break; } catch (NullReferenceException e) { Console.WriteLine(e); /* nom */ } } } if (data == null) { return(null); } // forces out the old lazy load, if used await _entityFlattener.FlattenAndStore(Bypass, data, false); return(await Bypass.GetEntity(id, true)); }
public virtual Community ToEntity() { long id; Community community = new Community() { Book = new Book() { Id = this.BookId }, Package = this.Package, ListingTypes = ConverterHelpers.CheckBoxListToEnumList <ListingType>(this.ListingTypes), SeniorHousingAndCareCategoryIds = ConverterHelpers.CheckBoxListToLongArray(this.SeniorHousingAndCareCategories), AgeRestrictions = ConverterHelpers.CheckBoxListToEnumList <AgeRestriction>(this.AgeRestrictions), Name = this.Name, Address = (this.AddressValidation.ValidationItems == null ? this.Address.ToEntity() : this.AddressValidation.ToEntity()), DisplayAddress = !this.DoNotDisplayAddress, Phones = this.PhoneList.ToEntityList(), Emails = this.EmailList.ToEntity(), Contacts = this.Contacts.ConvertAll <Contact>((ContactVm m) => m.ToEntity()).Where <Contact>((Contact x) => { if (!string.IsNullOrWhiteSpace(x.FirstName)) { return(true); } return(!string.IsNullOrWhiteSpace(x.LastName)); }).ToList <Contact>(), OfficeHours = ( from m in this.OfficeHours select m.ToEntity()).ToList <MSLivingChoices.Entities.Admin.OfficeHours>(), Description = this.Description, WebsiteUrl = MslcUrlBuilder.NormalizeUri(this.WebsiteUrl), DisplayWebsiteUrl = this.DisplayWebsiteUrl }; List <long> paymentTypeIds = new List <long>(); foreach (CheckBoxVm checkBoxVm in from m in this.CommunityDetails.PaymentTypes where m.IsChecked select m) { if (!long.TryParse(checkBoxVm.Value, out id)) { continue; } paymentTypeIds.Add(id); } community.PaymentTypeIds = paymentTypeIds; community.PriceRange = this.CommunityDetails.PriceRange.ToEntity(); community.Deposit = this.CommunityDetails.Deposit.ToEntity(); community.ApplicationFee = this.CommunityDetails.ApplicationFee.ToEntity(); community.PetDeposit = this.CommunityDetails.PetDeposit.ToEntity(); community.BedroomFromId = this.CommunityDetails.BedroomFromId; community.BedroomToId = this.CommunityDetails.BedroomToId; community.BathroomFromId = this.CommunityDetails.BathroomFromId; community.BathroomToId = this.CommunityDetails.BathroomToId; community.LivingSpace = this.CommunityDetails.LivingSpace.ToEntity(); community.UnitCount = this.CommunityDetails.UnitCount; community.Amenities = AmenityVm.ToEntityList(this.CommunityDetails.DefaultAmenities, this.CommunityDetails.CustomAmenities); community.CommunityServices = CommunityServiceVm.ToEntityList(this.CommunityDetails.DefaultCommunityServices, this.CommunityDetails.CustomCommunityServices); community.FloorPlans = new List <FloorPlan>(); community.SpecHomes = new List <SpecHome>(); community.Houses = new List <House>(); community.VirtualTour = MslcUrlBuilder.NormalizeUri(this.CommunityDetails.VirtualTour); community.Coupon = this.CommunityDetails.Coupon.ToEntity(); community.Images = (this.CommunityDetails.Images == null ? new List <Image>() : this.CommunityDetails.Images.ToEntity(ImageType.Photo)); community.LogoImages = (this.CommunityDetails.LogoImages == null ? new List <Image>() : this.CommunityDetails.LogoImages.ToEntity(ImageType.Logo)); if (this.CommunityDetails.HasFloorPlans) { community.FloorPlans = ( from m in this.CommunityDetails.FloorPlans select m.ToEntity()).ToList <FloorPlan>(); community.FloorPlans.ForEach((FloorPlan m) => m.Community = community); } if (this.CommunityDetails.HasSpecHomes) { community.SpecHomes = ( from m in this.CommunityDetails.SpecHomes select m.ToEntity()).ToList <SpecHome>(); community.SpecHomes.ForEach((SpecHome m) => m.Community = community); } if (this.CommunityDetails.HasHouses) { community.Houses = ( from m in this.CommunityDetails.Houses select m.ToEntity()).ToList <House>(); community.Houses.ForEach((House m) => m.Community = community); } community.PropertyManager = this.ListingDetails.PropertyManager.ToEntity(OwnerType.PropertyManager); community.Builder = this.ListingDetails.Builder.ToEntity(OwnerType.Builder); community.CallTrackingPhones = new List <CallTrackingPhone>(); if (this.ListingDetails.CallTrackingPhones != null) { if (!this.ListingDetails.ProvisionCallTrackingNumbers) { this.ListingDetails.CallTrackingPhones.ForEach((CallTrackingPhoneVm c) => c.IsDisconnected = true); } community.CallTrackingPhones = ( from p in this.ListingDetails.CallTrackingPhones.ConvertAll <CallTrackingPhone>((CallTrackingPhoneVm x) => x.ToEntity()) where !string.IsNullOrEmpty(p.Phone) select p).ToList <CallTrackingPhone>(); } community.Publishing.StartDate = this.PublishStart; community.Publishing.EndDate = this.PublishEnd; community.Showcase.StartDate = this.ShowcaseStart; community.Showcase.EndDate = this.ShowcaseEnd; return(community); }
public async Task <APEntity> GetEntity(string id, bool doRemote) { if (id == "https://www.w3.org/ns/activitystreams#Public") { var aso = new ASObject(); aso.Type.Add("https://www.w3.org/ns/activitystreams#Collection"); aso.Id = "https://www.w3.org/ns/activitystreams#Public"; var ent = APEntity.From(aso); return(ent); } try { if ((new Uri(id)).Host == "localhost") { return(await Bypass.GetEntity(id, doRemote)); } } catch (UriFormatException) { /* nom */ } APEntity entity = null; if (Bypass != null) { entity = await Bypass.GetEntity(id, doRemote); } if (entity != null && !entity.IsOwner && entity.Data.Type.Any(_collections.Contains) && doRemote) { entity = null; } if (entity?.Type == "_:LazyLoad" && !doRemote) { return(null); } if ((entity != null && entity.Type != "_:LazyLoad") || !doRemote) { return(entity); } var loadUrl = id; if (entity?.Type == "_:LazyLoad") { loadUrl = (string)entity.Data["href"].First().Primitive; } if (loadUrl.StartsWith("tag:")) { return(null); } var htc = new HttpClient(); htc.DefaultRequestHeaders.TryAddWithoutValidation("Accept", "application/activity+json; application/ld+json; profile=\"https://www.w3.org/ns/activitystreams\", application/json, application/atom+xml, text/html"); if (_context != null) { var signatureVerifier = _serviceProvider.GetRequiredService <SignatureVerifier>(); var user = await Bypass.GetEntity(_context.User.FindFirstValue(JwtTokenSettings.ActorClaim), false); if (user != null) { var jwt = await signatureVerifier.BuildJWS(user, id); if (jwt != null) { htc.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", jwt); } } } HttpResponseMessage response = null; try { response = await htc.GetAsync(loadUrl); if (!response.IsSuccessStatusCode) { response = await htc.GetAsync(loadUrl + ".atom"); // hack! if (!response.IsSuccessStatusCode) { return(null); } } } catch (TaskCanceledException) { return(null); // timeout } catch (HttpRequestException) { return(null); } var converters = new List <IConverterFactory> { new AS2ConverterFactory(), new AtomConverterFactory(false) }; tryAgain: ASObject data = null; foreach (var converter in converters) { if (converter.CanParse && ConverterHelpers.GetBestMatch(converter.MimeTypes, response.Content.Headers.ContentType.ToString()) != null) { data = await converter.Build(_serviceProvider, null).Parse(await response.Content.ReadAsStreamAsync()); break; } } if (data == null) { if (response.Headers.Contains("Link")) { var split = string.Join(", ", response.Headers.GetValues("Link")).Split(new[] { ", " }, StringSplitOptions.RemoveEmptyEntries); foreach (var spl in split) { var args = spl.Split(';').Select(a => a.Trim()).ToArray(); if (args.Contains("rel=\"alternate\"") && args.Contains("type=\"application/atom+xml\"")) { response = await htc.GetAsync(args[0].Substring(1, args[0].Length - 2)); goto tryAgain; } } } try { var links = (await response.Content.ReadAsStringAsync()).Split('\n'); var alt = links.FirstOrDefault(a => a.Contains("application/atom+xml") && a.Contains("alternate")); if (alt == null) { return(null); } var l = XDocument.Parse(alt + "</link>").Root; if (l.Attribute(XNamespace.None + "type")?.Value == "application/atom+xml") { response = await htc.GetAsync(l.Attribute(XNamespace.None + "href")?.Value); goto tryAgain; } } catch (Exception) { } return(null); } // forces out the old lazy load, if used await _entityFlattener.FlattenAndStore(Bypass, data, false); return(await Bypass.GetEntity(id, true)); }