Exemple #1
0
        public bool IsTeamOverlapped(HealthPlanCriteriaTeamEditModel model)
        {
            using (var adapter = PersistenceLayer.GetDataAccessAdapter())
            {
                var linqMetaData = new LinqMetaData(adapter);

                var crterias = (from hpcqc in linqMetaData.HealthPlanCallQueueCriteria
                                where hpcqc.Id != model.CriteriaId && hpcqc.CallQueueId == model.CallQueueId &&
                                hpcqc.HealthPlanId == model.HealthPlanId
                                select hpcqc.Id);

                var endDate   = model.EndDate;
                var startDate = model.StartDate;

                var count = (from hpcta in linqMetaData.HealthPlanCriteriaTeamAssignment
                             where crterias.Contains(hpcta.HealthPlanCriteriaId) &&
                             (
                                 (
                                     endDate != null &&
                                     (
                                         (hpcta.EndDate.HasValue && startDate >= hpcta.StartDate && startDate <= hpcta.EndDate.Value)
                                         ||
                                         (hpcta.EndDate.HasValue && (hpcta.StartDate >= endDate && endDate <= hpcta.EndDate.Value))
                                         ||
                                         (hpcta.EndDate.HasValue && (hpcta.StartDate >= startDate && hpcta.StartDate <= endDate))
                                         ||
                                         (hpcta.EndDate.HasValue && (hpcta.EndDate >= startDate && hpcta.EndDate <= endDate))

                                     )
                                 )
                                 ||
                                 (
                                     endDate == null &&
                                     (
                                         (hpcta.EndDate.HasValue && startDate <= hpcta.EndDate.Value)
                                     )

                                 )
                                 ||
                                 (
                                     !hpcta.EndDate.HasValue && (hpcta.StartDate >= startDate || hpcta.StartDate <= startDate)
                                 )
                             )
                             select hpcta).Count();

                return(count > 1);
            }
        }
Exemple #2
0
        public void UpdateTeamAssignment(HealthPlanCriteriaTeamEditModel model)
        {
            using (var adapter = PersistenceLayer.GetDataAccessAdapter())
            {
                var entity = new HealthPlanCriteriaTeamAssignmentEntity()
                {
                    StartDate = model.StartDate,
                    EndDate   = model.EndDate,
                };

                entity.Fields["EndDate"].IsChanged = true;

                var bucket = new RelationPredicateBucket(HealthPlanCriteriaTeamAssignmentFields.HealthPlanCriteriaId == model.CriteriaId);
                bucket.PredicateExpression.AddWithAnd(HealthPlanCriteriaTeamAssignmentFields.TeamId == model.Id);

                adapter.UpdateEntitiesDirectly(entity, bucket);
            }
        }