private void detach_DemandAdjustments1(DemandAdjustment entity)
		{
			this.SendPropertyChanging();
			entity.TargetDemand = null;
		}
 partial void DeleteDemandAdjustment(DemandAdjustment instance);
		private void detach_DemandAdjustments(DemandAdjustment entity)
		{
			this.SendPropertyChanging();
			entity.SourceDemand = null;
		}
 partial void InsertDemandAdjustment(DemandAdjustment instance);
 partial void UpdateDemandAdjustment(DemandAdjustment instance);
 private void CheckDemandAdjustmentLimits (DemandAdjustment da)
 {
     if (da.TargetDemand == null || da.SourceDemand == null || da.TargetDemand.Limit == null || da.SourceDemand.Limit == null)
         throw new InvalidOperationException("В корректировке не заполнениы заявки и/или лимиты в этих заявках");
 }
        private bool CheckToSkipTargetDemandLimitExecutorSighting(DemandAdjustment demandAdjustment)
        {
            try
            {
                CheckDemandAdjustmentLimits(demandAdjustment);
            }
            catch (InvalidOperationException)
            {
                return false;
            }

            return demandAdjustment.TargetDemand.Limit.ExecutorId == demandAdjustment.SourceDemand.Limit.ExecutorId && demandAdjustment.TargetDemand.Limit.ManagerId == demandAdjustment.SourceDemand.Limit.ManagerId;
        }
 private bool CheckToSkipTargetDemandLimitManagerSighting(DemandAdjustment da)
 {
     try
     {
         CheckDemandAdjustmentLimits(da);
     }
     catch (InvalidOperationException)
     {
         return false;
     }
     return (da.TargetDemand.Limit.ExecutorId == da.SourceDemand.Limit.ExecutorId && da.TargetDemand.Limit.ManagerId == da.SourceDemand.Limit.ManagerId) || (da.TargetDemand.Limit.ExecutorId == da.TargetDemand.Limit.ManagerId);
 }
        private bool CheckToSkipUPKZSighting (DemandAdjustment da)
        {
            if (SecurityEntityService.CheckTrusteeWithIdIsInRole(da.CreatorId, BudgetRole.Curator)
                        || SecurityEntityService.CheckTrusteeWithIdIsInRole(da.CreatorId, BudgetRole.UPKZHead))
                return true;

            return false;
        }
 private bool CheckLimitIsContingency (DemandAdjustment demandAdjustment)
 {
     return (demandAdjustment.SourceDemandId.HasValue && demandAdjustment.SourceDemand.Limit != null  && demandAdjustment.SourceDemand.Limit.TypeId == 1) ||
            (demandAdjustment.TargetDemandId.HasValue && demandAdjustment.TargetDemand.Limit != null && demandAdjustment.TargetDemand.Limit.TypeId == 1);
 }