public bool AddData(MultiModel multiModel) { try { multiModel.PersonDataTable.AddressData = multiModel.AddressDataTable; multiModel.PersonDataTable.DetailsData = multiModel.DetailsDataTable; databaseContext.PersonData.Add(multiModel.PersonDataTable); databaseContext.SaveChanges(); SQLConnection.UpdateTableCount(1); return(true); } catch (Exception Ex) { LogWriter.Exception("Error updating data.", Ex); return(false); } }
public bool DeleteData(MultiModel multiModel) { try { // Although my SQL table is set to cascade, I am going to be safe and delete the tables individually. databaseContext.Entry(multiModel.AddressDataTable).State = EntityState.Deleted; databaseContext.Entry(multiModel.DetailsDataTable).State = EntityState.Deleted; databaseContext.SaveChanges(); databaseContext.Entry(multiModel.PersonDataTable).State = EntityState.Deleted; databaseContext.SaveChanges(); SQLConnection.UpdateTableCount(-1); return(true); } catch (Exception Ex) { LogWriter.Exception("Error updating data.", Ex); return(false); } }