Exemple #1
0
        public Object EditPerson(string personId)
        {
            Person person = null;

            if (personId.IsNotNullOrWhiteSpace())
            {
                var query = new Query("Data.Scripts.GetPersonByID", typeof(Person))
                {
                    new Query.Param("pID", personId)
                };
                var ds = App.DataStore as MySQLDataStore;
                person = ds.LoadOneRow(query) as Person;
            }

            if (person == null)
            {
                person = new Person {
                    ID = Guid.NewGuid().ToString("N"), Age = 18
                }
            }
            ;

            Exception            validationError = null;
            RecordModelGenerator gen             = new RecordModelGenerator();
            string personDef = gen.RowToRecordInitJSON(person, validationError).ToJSON();

            return(new Edit {
                PersonDef = personDef
            });
        }
Exemple #2
0
        public Object Index()
        {
            Person pers = new Person {
                FirstName = "John", LastName = "Smith", Age = 20, IsCertified = true
            };

            Exception validationError = null; // pers.Validate();

            RecordModelGenerator gen = new RecordModelGenerator();
            string personDef         = gen.RowToRecordInitJSON(pers, validationError).ToJSON();

            return(new Index {
                PersonDef = personDef
            });
        }
    public Object SavePerson(Person person)
    {
      var validationError = person.Validate();
      if (validationError == null)
      {
        var ds = App.DataStore as MySQLDataStore;
        ds.StringBool = false;
        ds.Upsert(person);
        return new Redirect("/");
      }

      RecordModelGenerator gen = new RecordModelGenerator();
      string personDef = gen.RowToRecordInitJSON(person, validationError).ToJSON();
      return new Edit { PersonDef = personDef };
    }
    public Object EditPerson(string personId)
    {
      Person person = null;
      if (personId.IsNotNullOrWhiteSpace())
      {
        var query = new Query("Data.Scripts.GetPersonByID", typeof(Person)) { new Query.Param("pID", personId) };
        var ds = App.DataStore as MySQLDataStore;
        person = ds.LoadOneRow(query) as Person;
      }

      if (person == null)
        person = new Person { ID = Guid.NewGuid().ToString("N"), Age = 18 };

      Exception validationError = null;
      RecordModelGenerator gen = new RecordModelGenerator();
      string personDef = gen.RowToRecordInitJSON(person, validationError).ToJSON();
      return new Edit { PersonDef = personDef };
    }
Exemple #5
0
        public Object SavePerson(Person person)
        {
            var validationError = person.Validate();

            if (validationError == null)
            {
                var ds = App.DataStore as MySQLDataStore;
                ds.StringBool = false;
                ds.Upsert(person);
                return(new Redirect("/"));
            }

            RecordModelGenerator gen = new RecordModelGenerator();
            string personDef         = gen.RowToRecordInitJSON(person, validationError).ToJSON();

            return(new Edit {
                PersonDef = personDef
            });
        }
Exemple #6
0
 public static string FormJSON(Person person, Exception validationError = null)
 {
     return(RecordModelGenerator.RowToRecordInitJSON(person, validationError).ToJSON());
 }