public MethodResult <Person> AddPerson(PersonBlank blank) { using (var command = connection.CreateCommand()) { command.CommandText = "INSERT INTO [person] (name, phone, address) VALUES(@name, @phone, @address);"; command.Parameters.Add(new SQLiteParameter("@name", blank.Name) { DbType = DbType.String }); command.Parameters.Add(new SQLiteParameter("@phone", blank.Phone) { DbType = DbType.String }); command.Parameters.Add(new SQLiteParameter("@address", blank.Address) { DbType = DbType.String }); var result = ExecuteNonQuery(command); if (!result.Success) { return(new MethodResult <Person>(null, result.Description)); } return(new MethodResult <Person>(new Person(result.Value, blank))); } }
public MethodResult <Person> AddPerson(PersonBlank blank) { var result = DataBaseManager.Instance.AddPerson(blank); if (result.Success && PersonChanged != null) { PersonChanged(this, new ItemChangedEventArgs <Person>(result.Value, ItemChangedEventArgs <Person> .ActionType.Add)); } return(result); }
public Person(int id, PersonBlank blank) : this(id) { Name = blank.Name; Phone = blank.Phone; Address = blank.Address; }