Exemple #1
0
        public OnlineHealthAssessmentQuestionModel Get(OnlineHealthAssessmentQuestionModel model)
        {
            var tempCart   = model.RequestValidationModel.TempCart;
            var eventId    = tempCart.EventId.Value;
            var customerId = tempCart.CustomerId.Value;

            var customer                = _customerRepository.GetCustomer(customerId);
            var iskynPurchased          = IsTestPurchased(eventId, tempCart.CustomerId.Value, (long)TestType.Kyn);
            var isKynIntegrationEnabled = _eventPodRepository.IsKynIntegrationEnabled(eventId);

            model.HafModel = _customerHafQuestionService.Get(new HafFilter
            {
                CustomerId       = tempCart.CustomerId.Value,
                EventId          = tempCart.EventId.Value,
                SetChildQuestion = true,
                VersionNumber    = 0
            });

            model.Height         = customer.Height != null ? (int)customer.Height.TotalInches : 0;
            model.Weight         = customer.Weight != null ? (int)customer.Weight.Pounds : 0;
            model.Race           = (int)customer.Race;
            model.Waist          = customer.Waist;
            model.IsKynPurchased = isKynIntegrationEnabled && iskynPurchased;

            return(model);
        }
        public HafModel Get(HafFilter filter)
        {
            var theEvent = _eventRepository.GetById(filter.EventId);

            if (!theEvent.HealthAssessmentTemplateId.HasValue || theEvent.HealthAssessmentTemplateId.Value <= 0)
            {
                return(null);
            }

            var customer = _customerRepository.GetCustomer(filter.CustomerId);

            var template           = _healthAssessmentTemplateRepository.GetById(theEvent.HealthAssessmentTemplateId.Value);
            var genericQuestionIds = new List <long>();
            var list = new List <KeyValuePair <long, List <long> > >();

            IsFemale = customer.Gender == Gender.Female;

            //Get Generic Question from Event Templates
            genericQuestionIds.AddRange(template.QuestionIds);

            var order          = _orderRepository.GetOrder(filter.CustomerId, filter.EventId);
            var eventpackageId = order.OrderDetails.Where(od => od.OrderItemStatus.OrderStatusState == OrderStatusState.FinalSuccess && od.OrderItem.OrderItemType == OrderItemType.EventPackageItem).Select(od => od.OrderItem.ItemId).FirstOrDefault();

            var isKynIntegrationEnabled = _eventPodRepository.IsKynIntegrationEnabled(filter.EventId);
            var eventTestIds            = new List <long>();

            if (eventpackageId > 0)
            {
                var eventPackage = _eventPackageRepository.GetById(eventpackageId);

                if (eventPackage.HealthAssessmentTemplateId.HasValue && eventPackage.HealthAssessmentTemplateId.Value > 0)
                {
                    var packageTemplate = _healthAssessmentTemplateRepository.GetById(eventPackage.HealthAssessmentTemplateId.Value);
                    genericQuestionIds.AddRange(packageTemplate.QuestionIds);
                }

                eventTestIds.AddRange(eventPackage.Tests.Select(t => t.Id));
            }
            list.Add(new KeyValuePair <long, List <long> >(0, genericQuestionIds));

            eventTestIds.AddRange(order.OrderDetails.Where(od => od.OrderItemStatus.OrderStatusState == OrderStatusState.FinalSuccess && od.OrderItem.OrderItemType == OrderItemType.EventTestItem).Select(od => od.OrderItem.ItemId));
            var eventTests = _eventTestRepository.GetbyIds(eventTestIds);

            var testWiseQuestion = GetTestQuestionKeyValuePairs(eventTestIds, isKynIntegrationEnabled, eventTests);

            if (testWiseQuestion != null)
            {
                list.AddRange(testWiseQuestion);
            }

            var hafModel = GetHafModel(list, eventTests, filter.EventId, filter.CustomerId, filter.SetChildQuestion, filter.VersionNumber) ?? new HafModel();

            hafModel.EventId    = filter.EventId;
            hafModel.CustomerId = filter.CustomerId;
            return(hafModel);
        }
        public KynNotificationViewModel IsApplicableForNotification(EventCustomer eventCustomer)
        {
            if (!eventCustomer.AppointmentId.HasValue)
            {
                return(null);
            }

            var isKynIntegrationEnabled = _eventPodRepository.IsKynIntegrationEnabled(eventCustomer.EventId);

            if (!isKynIntegrationEnabled)
            {
                return(null);
            }

            var tests = _eventCustomerPackageTestDetailService.GetTestsPurchasedByCustomer(eventCustomer.EventId, eventCustomer.CustomerId);
            var isKynTestPurchased = tests != null && tests.Any(t => t.Id == (long)TestType.Kyn);

            if (!isKynTestPurchased)
            {
                return(null);
            }

            var customer = _customerRepository.GetCustomer(eventCustomer.CustomerId);

            var isDemographicInfoFilled = CheckDemographicInfo(customer);

            var isHafFilled = _kynHealthAssessmentHelper.IsKynHafFilled(eventCustomer.EventId, eventCustomer.CustomerId);

            if (isDemographicInfoFilled && isHafFilled)
            {
                return(null);
            }

            var eventHostViewData = _eventService.GetById(eventCustomer.EventId);
            var appointment       = _appointmentRepository.GetById(eventCustomer.AppointmentId.Value);

            return(_notificationModelsFactory.GetKynNotificationViewModel(customer, eventHostViewData, appointment, isDemographicInfoFilled, isHafFilled));
        }