Esempio n. 1
0
        static void Main()
        {
            Db.Transact(() =>
            {
                var anyone = Db.SQL <Person>("SELECT p FROM Person p").First;
                if (anyone == null)
                {
                    new Person
                    {
                        FirstName = "John",
                        LastName  = "Doe"
                    };
                }
            });

            Application.Current.Use(new HtmlFromJsonProvider());
            Application.Current.Use(new PartialToStandaloneHtmlProvider());

            Handle.GET("/HelloWorld", () =>
            {
                var person = Db.SQL <Person>("SELECT p FROM Person p").First;
                var json   = new PersonJson
                {
                    Data = person
                };

                if (Session.Current == null)
                {
                    Session.Current = new Session(SessionOptions.PatchVersioning);
                }
                json.Session = Session.Current;
                return(json);
            });
        }
Esempio n. 2
0
        static void Main()
        {
            //on the first run, create the initial Person object
            var person = Db.SQL <Person>("SELECT p FROM Person p").First;

            if (person == null)
            {
                Db.Transact(() => {
                    new Person()
                    {
                        FirstName = "Martin"
                    };
                });
            }

            Application.Current.Use(new HtmlFromJsonProvider());
            Application.Current.Use(new PartialToStandaloneHtmlProvider());

            //create HTTP handler
            Handle.GET("/HelloWorld", () => {
                return(Db.Scope(() => {
                    var json = new PersonJson()
                    {
                        Data = Db.SQL <Person>("SELECT p FROM Person p").First
                    };
                    json.NewExpense.Data = new Expense()
                    {
                        Amount = 1
                    };
                    json.Session = new Session(SessionOptions.PatchVersioning);
                    return json;
                }));
            });
        }