Exemple #1
0
        public void Test2()
        {
            Solidbase list = new Solidbase("Random");
            var       e    = list.First();

            list.Remove(e);
        }
Exemple #2
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseWire(env);
            Solidbase.Strategy = () => new SqlConnection("Server=.\\SQLEXPRESS;Database=NewSolidb;Trusted_Connection=True;");
            API.GET("/api/{Type}", x =>
            {
                Solidbase list = new Solidbase(x.Parameters.Type);
                return(list.ToList());
            });
            API.GET("/api/{Type}/{Id}", x =>
            {
                Solidbase list = new Solidbase(x.Parameters.Type);
                return(list.FirstOrDefault(z => z.Id == x.Parameters.Id));
            });
            API.POST("/api/{Type}", x =>
            {
                Solidbase list = new Solidbase(x.Parameters.Type);
                list.Add(x.Body.As <dynamic>());
                return(list.ToList());
            });
            API.DELETE("/api/{Type}/{Id}", x =>
            {
                Solidbase list = new Solidbase(x.Parameters.Type);
                var itm        = list.FirstOrDefault(z => z.Id == x.Parameters.Id);
                list.Remove(itm);
                return(true);
            });

            //API.Plugins.AddJwt(x => x.Username == x.Password, JwtMode.Session);

            API.Conditions.Add("Authentication", x => x.HttpContext.User.Identity.IsAuthenticated);

            API.GET("/peep", x => "Hello There..", API.Conditions["Authentication"]);
        }