Ejemplo n.º 1
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 };
    }
Ejemplo n.º 2
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 };
    }