Пример #1
0
        //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);
        }
Пример #2
0
        //public bool DeleteAll( Entity parent, ref SaveStatus status, DateTime? lastUpdated = null )
        //{
        //	bool isValid = true;
        //	if ( parent == null || parent.Id == 0 )
        //	{
        //		status.AddError( thisClassName + ". Error - the provided target parent entity was not provided." );
        //		return false;
        //	}
        //	int expectedDeleteCount = 0;
        //	try
        //	{
        //		using ( var context = new EntityContext() )
        //		{
        //			var results = context.Entity_CostProfile.Where( s => s.EntityId == parent.Id && ( lastUpdated == null || s.LastUpdated < lastUpdated ) )
        //		.ToList();
        //			if ( results == null || results.Count == 0 )
        //				return true;
        //			expectedDeleteCount = results.Count;

        //			foreach ( var item in results )
        //			{
        //				context.Entity_CostProfile.Remove( item );
        //				var count = context.SaveChanges();
        //				if ( count > 0 )
        //				{

        //				}
        //			}
        //		}
        //	}
        //	catch ( System.Data.Entity.Infrastructure.DbUpdateConcurrencyException dbcex )
        //	{
        //		if ( dbcex.Message.IndexOf( "an unexpected number of rows (0)" ) > 0 )
        //		{
        //			//don't know why this happens, quashing for now.
        //			LoggingHelper.DoTrace( 1, string.Format( thisClassName + ".DeleteAll. Parent type: {0}, ParentId: {1}, expectedDeletes: {2}. Message: {3}", parent.EntityTypeId, parent.EntityBaseId, expectedDeleteCount, dbcex.Message ) );
        //		}
        //		else
        //		{
        //			var msg = BaseFactory.FormatExceptions( dbcex );
        //			LoggingHelper.DoTrace( 1, string.Format( thisClassName + ".DeleteAll. ParentType: {0}, baseId: {1}, DbUpdateConcurrencyException: {2}", parent.EntityType, parent.EntityBaseId, msg ) );
        //		}

        //	}
        //	catch ( Exception ex )
        //	{
        //		var msg = BaseFactory.FormatExceptions( ex );
        //		LoggingHelper.DoTrace( 1, string.Format( thisClassName + ".DeleteAll. ParentType: {0}, baseId: {1}, exception: {2}", parent.EntityType, parent.EntityBaseId, msg ) );
        //	}
        //	return isValid;
        //}
        //
        private bool UpdateParts(ThisEntity entity, ref SaveStatus status)
        {
            bool isAllValid = true;

            //
            try
            {
                if (new Entity_ReferenceManager().Add(entity.Condition, entity.RowId, CodesManager.ENTITY_TYPE_COST_PROFILE, ref status, CodesManager.PROPERTY_CATEGORY_CONDITION_ITEM, false) == false)
                {
                    isAllValid = false;
                }

                //JurisdictionProfile
                Entity_JurisdictionProfileManager jpm = new Entity_JurisdictionProfileManager();
                jpm.SaveList(entity.Jurisdiction, entity.RowId, Entity_JurisdictionProfileManager.JURISDICTION_PURPOSE_SCOPE, ref status);
            }
            catch (Exception ex)
            {
                LoggingHelper.DoTrace(1, thisClassName + ".UpdateParts(). Exception while processing condition/jurisdiction. " + ex.Message);
                status.AddError(ex.Message);
            }


            if (entity.Items != null && entity.Items.Count > 0)
            {
                new CostProfileItemManager().SaveList(entity.Items, entity.Id, ref status);
            }

            return(isAllValid);
        }
Пример #3
0
        /// <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);
        }
        private bool UpdateParts(ThisEntity entity, ref SaveStatus status)
        {
            bool isAllValid = true;

            if (new Entity_ReferenceManager().Add(entity.Condition, entity.RowId, CodesManager.ENTITY_TYPE_CONDITION_PROFILE, ref status, CodesManager.PROPERTY_CATEGORY_CONDITION_ITEM, false) == false)
            {
                isAllValid = false;
            }

            //JurisdictionProfile
            Entity_JurisdictionProfileManager jpm = new Entity_JurisdictionProfileManager();

            jpm.SaveList(entity.Jurisdiction, entity.RowId, Entity_JurisdictionProfileManager.JURISDICTION_PURPOSE_SCOPE, ref status);

            if (entity.Items != null && entity.Items.Count > 0)
            {
                new CostProfileItemManager().SaveList(entity.Items, entity.Id, ref status);
            }

            return(isAllValid);
        }