//public bool DeleteAll( Entity parent, ref SaveStatus status ) //{ // bool isValid = true; // //Entity parent = EntityManager.GetEntity( parentUid ); // if ( parent == null || parent.Id == 0 ) // { // status.AddError( thisClassName + ".DeleteAll Error - the provided target parent entity was not provided." ); // return false; // } // using ( var context = new EntityContext() ) // { // context.HoldersProfile.RemoveRange( context.HoldersProfile.Where( s => s.EntityId == parent.Id ) ); // int count = context.SaveChanges(); // if ( count > 0 ) // { // isValid = true; // } // else // { // //if doing a delete on spec, may not have been any properties // } // } // return isValid; //} /// <summary> /// Parts: /// - Jurisdiction /// - DataSetProfile /// </summary> /// <param name="entity"></param> /// <param name="status"></param> /// <returns></returns> public bool UpdateParts(ThisEntity entity, ref SaveStatus status) { bool isAllValid = true; Entity relatedEntity = EntityManager.GetEntity(entity.RowId); if (relatedEntity == null || relatedEntity.Id == 0) { status.AddError("Error - the related Entity was not found."); return(false); } //JurisdictionProfile Entity_JurisdictionProfileManager jpm = new Entity_JurisdictionProfileManager(); //do deletes - NOTE: other jurisdictions are added in: UpdateAssertedIns jpm.DeleteAll(relatedEntity, ref status); if (!jpm.SaveList(entity.Jurisdiction, entity.RowId, Entity_JurisdictionProfileManager.JURISDICTION_PURPOSE_SCOPE, ref status)) { isAllValid = false; } //datasetProfiles if (!new DataSetProfileManager().SaveList(entity.RelevantDataSet, relatedEntity, ref status)) { isAllValid = false; } return(isAllValid); }
/// <summary> /// Parts: /// - Jurisdiction /// - DataSetProfile /// </summary> /// <param name="entity"></param> /// <param name="status"></param> /// <returns></returns> public bool UpdateParts(ThisEntity entity, ref SaveStatus status) { bool isAllValid = true; Entity relatedEntity = EntityManager.GetEntity(entity.RowId); if (relatedEntity == null || relatedEntity.Id == 0) { status.AddError("Error - the related Entity was not found."); return(false); } //ProcessProfile Entity_ProcessProfileManager ppm = new Factories.Entity_ProcessProfileManager(); ppm.DeleteAll(relatedEntity, ref status); try { ppm.SaveList(entity.AdministrationProcess, Entity_ProcessProfileManager.ADMIN_PROCESS_TYPE, entity.RowId, ref status); } catch (Exception ex) { string message = FormatExceptions(ex); LoggingHelper.LogError(ex, thisClassName + string.Format(".AddProfiles() - ProcessProfiles. id: {0}", entity.Id)); status.AddWarning(thisClassName + ".AddProfiles(). Exceptions encountered handling ProcessProfiles. " + message); } // Entity_ReferenceFrameworkManager erfm = new Entity_ReferenceFrameworkManager(); erfm.DeleteAll(relatedEntity, ref status); if (erfm.SaveList(relatedEntity.Id, CodesManager.PROPERTY_CATEGORY_CIP, entity.InstructionalProgramTypes, ref status) == false) { isAllValid = false; } //JurisdictionProfile Entity_JurisdictionProfileManager jpm = new Entity_JurisdictionProfileManager(); //do deletes - NOTE: other jurisdictions are added in: UpdateAssertedIns jpm.DeleteAll(relatedEntity, ref status); jpm.SaveList(entity.Jurisdiction, entity.RowId, Entity_JurisdictionProfileManager.JURISDICTION_PURPOSE_SCOPE, ref status); //datasetProfiles new DataSetTimeFrameManager().SaveList(entity.DataSetTimePeriod, entity.Id, ref status); return(isAllValid); }