public int AddGuardian(Guardian guardian, string connectionString) { int id; using (BennetBasketballDb db = new BennetBasketballDb(connectionString)) { db.Guardians.Add(guardian); db.SaveChanges(); id = guardian.Id; } return id; }
public void AddRegistration(Guardian guardian, Player player, string connectionString) { int? guardianId = guardian.Id; if (guardianId == null) { GuardianAccessor guardianAccessor = new GuardianAccessor(); guardianId=guardianAccessor.AddGuardian(guardian, connectionString); } PlayerAccessor playerAccessor = new PlayerAccessor(); player.GuardianId = guardianId; playerAccessor.AddPlayer(player, connectionString); }