public void SaveChildInfo() { using (var context = new CCAppEntities()) { // verify data if (VerifyChildInfo()) { // open DB context.Database.Connection.Open(); // CRUD context.Child.Add(new Child { ChildFirstName = this.ChildFirstName, ChildMiddleName = this.ChildMiddleName, ChildLastName = this.ChildLastName, ChildBirthDate = this.ChildBirthDate, ChildIsActive = this.ChildIsActive, ChildAddress = this.ChildAddress, ChildCity = this.ChildCity, ChildState = this.ChildState, ChildGender = this.ChildGender, ChildZip = this.ChildZip, ChildPhone = this.ChildPhone }); // save child to db context.SaveChanges(); ClearChildInfo(); } } }
public void SaveChildInfo() { SetCurentChild(); using (var context = new CCAppEntities()) { context.Database.Connection.Open(); if (SelectedChildInfo != null) { var childToSave = context.Child.Find(SelectedChildInfo.Id); SetChildProperties(childToSave); int saveCode = context.SaveChanges(); } } }
public void SaveCompanyInfo() { //open database and get company object var company = new Company(); using (var context = new CCAppEntities()) { context.Database.Connection.Open(); company = context.Company.FirstOrDefault <Company>(); company.CompanyAddress = CompanyAddress; company.CompanyEmail = CompanyEmail; company.CompanyName = CompanyName; company.CompanyOwner = CompanyOwner; company.CompanyPhone = CompanyPhone; int saveCode = context.SaveChanges(); } }