public bool SavePerson(Person p) { db.People.Add(p); db.SaveChanges(); return true; }
public static Person CreatePerson() { var p = new Person(); p.Position = string.Format("{0} of {1}", GetItem(_positions), GetItem(_areas)); p.Name = string.Format("{0} {1}", GetItem(_first), GetItem(_last)); p.Notes = string.Format("{0} {1} {2} {3}", p.Name, GetItem(_verb), GetItem(_adjective), GetItem(_noun)); while (_rnd.NextDouble() < .5) { p.Notes += string.Format(" and {0} {1} {2}", GetItem(_verb), GetItem(_adjective), GetItem(_noun)); } p.Notes += "."; return p; }
public void InsertAndMapBack() { Person e = new Person(); e.FirstName = "Crazy"; e.LastName = "Frog"; e.Gender = Gender.Other; using (DbManager db = new DbManager()) { db .SetSpCommand("Person_Insert", db.CreateParameters(e, new string[] { "PersonID" }, null, null)) .ExecuteObject(e); Assert.IsTrue(e.ID > 0); // Cleanup. // db .SetSpCommand("Person_Delete", db.CreateParameters(e)) .ExecuteNonQuery(); } }
public static void Write(Person person) { Debug.WriteLine("INSERT person with name " + person.Name); }
public static void Delete(Person person) { Debug.WriteLine("DELETE person with name " + person.Name); }