/// <summary> /// On save click - beware some funky logic included here if user is trying to UPDATE an existing profile... /// </summary> private void btnSaveChanges_Click(object sender, EventArgs e) { updateProfileDataSource(); updateFaultListDataSource(); Page.Validate("MinimumProfileDetails"); if (Page.IsValid) { try { // get the currently Assigned vehicles (if any) Fleetwood.BlueSphere.BusinessLogic.VehicleList assignedVehicles = CurrentProfile.VehicleList; //when profiels are updated this actually creates a new one Guid newProfileID = CurrentProfile.Update(); CurrentProfile = new Fleetwood.BlueSphere.BusinessLogic.SafetyCheckProfile(newProfileID); foreach (Fleetwood.BlueSphere.BusinessLogic.FaultType item in CurrentProfileFaultList) { if (item.SafetyCheckProfileID != new Guid("00000000-0000-0000-0000-000000000000")) { Fleetwood.BlueSphere.BusinessLogic.FaultType clonedFault = item.Clone(); clonedFault.SafetyCheckProfileID = CurrentProfile.ID; clonedFault.IsDeleted = false; clonedFault.Update(); } else { item.SafetyCheckProfileID = CurrentProfile.ID; item.Update(); } } // Now we need to re-ssign any vehicles that had the old Id to the new one. ArrayList assignments = new ArrayList(); foreach (Fleetwood.BlueSphere.BusinessLogic.Vehicle v in assignedVehicles) { assignments.Add(v.ID); } CurrentProfile.AssignVehicles(assignments); saveProfileError.Visible = false; Response.Redirect(Request.RawUrl); } catch (Exception ex) { saveProfileError.Visible = true; saveProfileError.InnerText = ex.Message; } } }