public FamilyMember AssignGroups() { var groupRepo = new GroupNameRepository(); var groupNameList = groupRepo.GetGroupNames(); FamilyMember fam = new FamilyMember(); fam.GroupNameList = groupNameList; if (fam.GroupID == 1) { fam.GroupName = "Tisdale"; } if (fam.GroupID == 2) { fam.GroupName = "Denny"; } if (fam.GroupID == 3) { fam.GroupName = "Harkness"; } if (fam.GroupID == 4) { fam.GroupName = "Littleton"; } if (fam.GroupID == 5) { fam.GroupName = "Elliot"; } if (fam.GroupID == 6) { fam.GroupName = "Lee"; } return(fam); }
public FamilyMember GetFamilyMember(int id) { MySqlConnection conn = new MySqlConnection(connectionString); MySqlCommand cmd = conn.CreateCommand(); cmd.CommandText = "SELECT * FROM FamilyMembers WHERE ID = @id;"; cmd.Parameters.AddWithValue("id", id); using (conn) { conn.Open(); MySqlDataReader reader = cmd.ExecuteReader(); var familyMember = new FamilyMember(); while (reader.Read() == true) { FamilyMember currentFamilyMember = new FamilyMember(); familyMember.ID = reader.GetInt32("ID"); try { familyMember.GroupID = reader.GetInt32("GroupID"); } catch (System.Data.SqlTypes.SqlNullValueException) { familyMember.GroupID = null; } familyMember.FirstName = reader.GetString("FirstName"); familyMember.LastName = reader.GetString("LastName"); var groupRepo = new GroupNameRepository(); groupRepo.AssignGroupNameToFamilyMember(familyMember); try { familyMember.AstroSign = reader.GetString("AstroSign"); } catch (System.Data.SqlTypes.SqlNullValueException) { AssignAstroSign(familyMember); } familyMember.BirthDay = reader.GetInt32("BirthDay"); familyMember.BirthMonth = reader.GetInt32("BirthMonth"); familyMember.BirthYear = reader.GetInt32("BirthYear"); familyMember.Gender = reader.GetString("Gender"); try { familyMember.MaidenName = reader.GetString("MaidenName"); } catch (System.Data.SqlTypes.SqlNullValueException) { familyMember.MaidenName = null; } try { familyMember.Generation = reader.GetString("Generation"); } catch (System.Data.SqlTypes.SqlNullValueException) { AssignGeneration(familyMember); } } return(familyMember); } }