public static void AddNewContact(DeserializedPerson person) { Person p = new Person { firstName = person.firstName, lastName = person.lastName }; Person_address pa = new Person_address { houseNum = person.houseNum, street = person.street, address_city = person.city, address_state = person.state, address_country = person.country, zipcode = person.zipcode }; pa.People.Add(p); Person_phone pp = new Person_phone { countryCode = person.countryCode, areaCode = person.areaCode, number = person.number, ext = person.ext, Person = p }; AddToDatabase(p); AddToDatabase(pa); AddToDatabase(pp); }
public static Person_address FindAddressID(int ID) { try { Person_address address = db.Person_address.Single(pa => pa.Aid == ID); return(address); } catch (Exception ex) { logger.Error(ex, "DatabaseAction.Find Null Error"); return(null); } }
public static Person_address AddNewContact(Person p, string hnum, string street, string city, string state, string country, int zipcode) { pa = new Person_address { houseNum = hnum, street = street, address_city = city, address_state = state, address_country = country, zipcode = zipcode }; pa.People.Add(p); return(pa); }
public static string Edit(ref int opt, Person_address address, string text) { switch (opt) { case 1: address.houseNum = text; return(Save()); case 2: address.street = text; return(Save()); case 3: address.address_city = text; return(Save()); case 4: try { address.address_state = Enum.GetName(typeof(State), Enum.Parse(typeof(State), text)); return(Save()); } catch (Exception ex) { logger.Error(ex, "DatabaseAction.Edit BadInput Error"); return("Invalid State!"); } case 5: try { address.address_country = Enum.GetName(typeof(Country), Enum.Parse(typeof(Country), text)); return(Save()); } catch (Exception ex) { logger.Error(ex, "DatabaseAction.Edit BadInput Error"); return("Invalid Country!"); } case 6: address.zipcode = Convert.ToInt32(text); return(Save()); default: return("No Information Updated"); } }
public static void AddToDatabase(Person_address pa) { db.Person_address.Add(pa); }
public static string Del(Person_address address) { db.Person_address.Remove(address); return(Save()); }