public async Task <Item> GetItem() { var manager = SquidexClientManager.FromOption(_configuration.ToSquidexOptions()); var clientInformation = manager.GetClient <Item, _Item>("information"); var resultInformation = await clientInformation.GetAsync(context : SquidexParser.DefaultContext("tr")); return(resultInformation.Items.FirstOrDefault()); }
public async Task <List <Item> > GetItems() { var manager = SquidexClientManager.FromOption(_configuration.ToSquidexOptions()); var clientExperience = manager.GetClient <Item, _Item>("experience"); var resultExperience = await clientExperience.GetAsync(context : SquidexParser.DefaultContext("tr")); return(resultExperience.Items.OrderBy(x => x.Data.OrderNo).ToList()); }
public void ConfigureServices(IServiceCollection services) { services.Configure <SquidexOptions>(Configuration.GetSection("app")); services.AddSingleton(c => SquidexClientManager.FromOption(c.GetRequiredService <IOptions <SquidexOptions> >().Value)); services.AddMvc(); }
public void ConfigureServices(IServiceCollection services) { services.Configure <SquidexOptions>(Configuration.GetSection("app")); services.Configure <SettingsData>(Configuration.GetSection("defaultSettings")); services.AddSingleton(c => SquidexClientManager.FromOption(c.GetRequiredService <IOptions <SquidexOptions> >().Value)); services.AddMemoryCache(); services.AddLocalization(options => { options.ResourcesPath = "Resources"; }); services.AddRouting(options => { options.LowercaseUrls = true; }); services.AddSingleton <IConfigureOptions <KeyManagementOptions> >(s => { return(new ConfigureOptions <KeyManagementOptions>(options => { options.XmlRepository = s.GetRequiredService <IXmlRepository>(); })); }); services.AddDataProtection().SetApplicationName("SquidexIdentity"); services.AddAuthentication() .AddCookie() .AddFacebook() .AddGoogle() .AddMicrosoftAccount() .AddTwitter(); services.ConfigureApplicationCookie(options => { options.LoginPath = "/login"; options.LogoutPath = "/logout"; options.AccessDeniedPath = "/accessdenied"; }); services.AddIdentity <UserEntity, RoleEntity>() .AddUserStore <UserStore>() .AddRoleStore <RoleStore>() .AddDefaultTokenProviders(); services.AddIdentityServer(options => { options.Events.RaiseSuccessEvents = true; options.Events.RaiseFailureEvents = true; options.Events.RaiseErrorEvents = true; options.Events.RaiseInformationEvents = true; options.UserInteraction.LoginUrl = "/login"; options.UserInteraction.LogoutUrl = "/logout"; options.UserInteraction.ErrorUrl = "/error"; options.UserInteraction.ConsentUrl = "/consent"; }) .AddAppAuthRedirectUriValidator() .AddAspNetIdentity <UserEntity>() .AddClientConfigurationValidator <DefaultClientConfigurationValidator>() .AddClientStore <ClientStore>() .AddDeveloperSigningCredential() .AddInMemoryCaching() .AddResourceStore <ResourceStore>(); services.AddMvc() .AddViewLocalization(options => { options.ResourcesPath = "Resources"; }) .AddDataAnnotationsLocalization(options => { options.DataAnnotationLocalizerProvider = (type, factory) => factory.Create(typeof(AppResources)); }) .AddRazorPagesOptions(options => { options.Conventions.AuthorizeFolder("/Manage"); options.Conventions.AuthorizePage("/Logout"); }); services.AddSingleton <HaveIBeenPwnedRestClient>(); services.AddAuthenticationConfigurator <FacebookOptions, FacebookHandler>( AuthenticationSchemeType.Facebook, Factories.OAuth <FacebookOptions>); services.AddAuthenticationConfigurator <GoogleOptions, GoogleHandler>( AuthenticationSchemeType.Google, Factories.OAuth <GoogleOptions>); services.AddAuthenticationConfigurator <MicrosoftAccountOptions, MicrosoftAccountHandler>( AuthenticationSchemeType.Microsoft, Factories.OAuth <MicrosoftAccountOptions>); services.AddAuthenticationConfigurator <TwitterOptions, TwitterHandler>( AuthenticationSchemeType.Twitter, Factories.Twitter); services.AddSingleton <IPasswordValidator <UserEntity>, PwnedPasswordValidator>(); services.AddSingleton <IEmailValidator, PwnedEmailValidator>(); services.AddSingleton <IAuthenticationSchemeProvider, SquidexAuthenticationSchemeProvider>(); services.AddSingleton <IAuthenticationSchemeStore, AuthenticationSchemeStore>(); services.AddSingleton <ISettingsProvider, SettingsProvider>(); services.AddSingleton <IEmailSender, EmailSender>(); var storeType = Configuration.GetValue <string>("store:type"); if (string.Equals(storeType, "MongoDB", StringComparison.OrdinalIgnoreCase)) { services.AddMongoDB(Configuration); } else { throw new ApplicationException("You have to define the store with 'store:type'. Allowed values: MongoDB"); } }