Пример #1
0
        public OnlineSchedulingProcessAndCartViewModel GetOnlineCart(TempCart tempCart)
        {
            var customer    = tempCart.CustomerId == null ? null : _customerRepository.GetCustomer(tempCart.CustomerId.Value);
            var appointment = tempCart.AppointmentId.HasValue
                                      ? _slotRepository.GetbyId(tempCart.AppointmentId.Value)
                                      : null;

            string sponsoredBy         = "";
            var    checkoutPhoneNumber = string.Empty;

            if (tempCart.EventId.HasValue)
            {
                var hospitalPartnerId = _hospitalPartnerRepository.GetHospitalPartnerIdForEvent(tempCart.EventId.Value);
                if (hospitalPartnerId > 0)
                {
                    var hospitalPartner =
                        _organizationRepository.GetOrganizationbyId(hospitalPartnerId);
                    sponsoredBy = hospitalPartner.Name;
                }
                var account = _corporateAccountRepository.GetbyEventId(tempCart.EventId.Value);
                if (account != null && account.CheckoutPhoneNumber != null && !string.IsNullOrWhiteSpace(PhoneNumber.ToNumber(account.CheckoutPhoneNumber.ToString())))
                {
                    checkoutPhoneNumber = account.CheckoutPhoneNumber.FormatPhoneNumber;
                }
            }

            return(_onlineSchedulingDataFactory.Create(tempCart, customer, appointment, sponsoredBy, checkoutPhoneNumber));
        }
Пример #2
0
        public JsonResult GetShippingOptionForEvent(long eventId)
        {
            var hospitalPartnerId = _hospitalPartnerRepository.GetHospitalPartnerIdForEvent(eventId);

            var shippingOptionViewModel = new ShippingOptionViewModel {
                IsHospitalPartnerEvent = false
            };

            if (hospitalPartnerId > 0)
            {
                shippingOptionViewModel = new ShippingOptionViewModel {
                    IsHospitalPartnerEvent = true
                };
                var shippingOptionsToBind = new List <ShippingOption>();

                var shippingOptions = _shippingOptionRepository.GetAllShippingOptionForHospitalPartner(hospitalPartnerId);

                if (shippingOptions != null && shippingOptions.Count > 0)
                {
                    shippingOptionsToBind.AddRange(shippingOptions);
                    shippingOptionViewModel.AllShippingOptions = Mapper.Map <IEnumerable <ShippingOption>, IEnumerable <ShippingOptionOrderItemViewModel> >(shippingOptionsToBind);
                }
            }

            return(Json(shippingOptionViewModel, JsonRequestBehavior.AllowGet));
        }
        public void PollforEventResultReadyNotification()
        {
            var notificationTypes = _notificationTypeRepository.GetAll();

            var notificationIsActive = notificationTypes.Any(nt => (nt.NotificationTypeAlias == NotificationTypeAlias.EventResultReadyNotification) && nt.IsActive);

            if (!notificationIsActive)
            {
                return;
            }

            var eventIds = _eventCustomerResultRepository.GetEventIdsForEventResultReadyNotiFication().ToArray();

            if (eventIds.Count() == 0)
            {
                return;
            }

            var createdByOrgRoleUserId = _organizationRoleUserRepository.GetOrganizationRoleUserIdsForRole((long)Roles.FranchisorAdmin).First();

            foreach (var eventId in eventIds)
            {
                try
                {
                    var notificationSent = _eventNotificationRepository.GetByEventId(eventId, NotificationTypeAlias.EventResultReadyNotification);
                    if (notificationSent != null)
                    {
                        continue;
                    }

                    var hospitalPartnerId = _hospitalPartnerRepository.GetHospitalPartnerIdForEvent(eventId);
                    if (hospitalPartnerId >= 1)
                    {
                        var partnerReleaseSinged = _eventCustomerResultRepository.CheckAnyCustomerResultsReadyAndSignedPartnerRelease(eventId);
                        if (partnerReleaseSinged)
                        {
                            var allResultsReady = _eventCustomerResultRepository.CheckAllCustomerResultsReadyForEvent(eventId);

                            if (!allResultsReady)
                            {
                                _logger.Info(string.Format("All Results are not ready For Event Id {0}", eventId));
                            }

                            var orgRoleUsers        = _organizationRoleUserRepository.GetOrganizationRoleUsersByOrganizationId(hospitalPartnerId);
                            var hospitalFacilityIds = _hospitalFacilityRepository.GetSelectedHospitalFacilityIdForEvent(eventId);
                            if (hospitalFacilityIds != null && hospitalFacilityIds.Any())
                            {
                                foreach (var hospitalFacilityId in hospitalFacilityIds)
                                {
                                    var hospitalFacilityOrgRoleUsers = _organizationRoleUserRepository.GetOrganizationRoleUsersByOrganizationId(hospitalFacilityId);
                                    if (hospitalFacilityOrgRoleUsers != null && hospitalFacilityOrgRoleUsers.Any())
                                    {
                                        orgRoleUsers = orgRoleUsers.Concat(hospitalFacilityOrgRoleUsers);
                                    }
                                }
                            }
                            var userIds = orgRoleUsers.Select(oru => oru.UserId).ToList();

                            var users             = _userRepository.GetUsers(userIds);
                            var eventHostViewData = _eventService.GetById(eventId);

                            foreach (var user in users)
                            {
                                if (user.Email == null || string.IsNullOrEmpty(user.Email.ToString()))
                                {
                                    continue;
                                }

                                var model         = _emailNotificationModelsFactory.GetEventResultReadyNotificationViewModel(user, eventHostViewData);
                                var notifications = _notifier.NotifySubscribersViaEmail(NotificationTypeAlias.EventResultReadyNotification, EmailTemplateAlias.EventResultReadyNotification, model, new string[] { user.Email.ToString() }, user.Id, createdByOrgRoleUserId, "Event Result Ready Notification");
                                if (notifications != null && notifications.Any())
                                {
                                    var eventNotification = new EventNotification {
                                        EventId = eventId, NotificationId = notifications.First().Id
                                    };
                                    _eventNotificationRepository.Save(eventNotification);
                                }
                            }
                        }
                    }

                    //var account = _corporateAccountRepository.GetbyEventId(eventId);
                    //if (account != null && account.Id > 0 && account.SendEventResultReadyNotification)
                    //{
                    //    var orgRoleUsers = _organizationRoleUserRepository.GetOrganizationRoleUsersByOrganizationIdAndRoleId(account.Id, (long)Roles.CorporateAccountCoordinator);

                    //    var userIds = orgRoleUsers.Select(oru => oru.UserId).ToList();

                    //    var users = _userRepository.GetUsers(userIds);
                    //    var eventHostViewData = _eventService.GetById(eventId);

                    //    foreach (var user in users)
                    //    {
                    //        if (user.Email == null || string.IsNullOrEmpty(user.Email.ToString()))
                    //            continue;

                    //        var model = _emailNotificationModelsFactory.GetEventResultReadyNotificationViewModel(user, eventHostViewData);
                    //        var notifications = _notifier.NotifySubscribersViaEmail(NotificationTypeAlias.EventResultReadyNotification, EmailTemplateAlias.EventResultReadyNotification, model, new string[] { user.Email.ToString() }, user.Id, createdByOrgRoleUserId, "Event Result Ready Notification");
                    //        if (notifications != null && notifications.Any())
                    //        {
                    //            var eventNotification = new EventNotification { EventId = eventId, NotificationId = notifications.First().Id };
                    //            _eventNotificationRepository.Save(eventNotification);
                    //        }
                    //    }
                    //}
                }
                catch (Exception ex)
                {
                    _logger.Error(string.Format("Event Result Ready Notification Error For Event Id {0} \nMessage:{1} \nStackTrace: {2}", eventId, ex.Message, ex.StackTrace));
                }
            }
        }
Пример #4
0
        public OnlineProductShippingEditModel GetShippingOption(TempCart tempCart)
        {
            var model = new OnlineProductShippingEditModel();

            if (tempCart.EventId != null)
            {
                var theEvent        = _eventRepository.GetById(tempCart.EventId.Value);
                var shippingOptions = _shippingOptionRepository.GetAllShippingOptionsForBuyingProcess();

                var shippingOptionsToBind = new List <ShippingOption>();
                if (theEvent.EventType == EventType.Retail)
                {
                    var hospitalPartnerId = _hospitalPartnerRepository.GetHospitalPartnerIdForEvent(tempCart.EventId.Value);
                    if (hospitalPartnerId > 0)
                    {
                        var hospitalPartner = _hospitalPartnerRepository.GetHospitalPartnerforaVendor(hospitalPartnerId);
                        if (hospitalPartner.ShowOnlineShipping)
                        {
                            var onlineShippingOption = _shippingOptionRepository.GetOnlineShippingOption();
                            shippingOptionsToBind.Add(onlineShippingOption);
                        }

                        model.IsHospitalPartnerEvent = true;

                        shippingOptions = _shippingOptionRepository.GetAllShippingOptionForHospitalPartner(hospitalPartnerId);
                        if (shippingOptions != null && shippingOptions.Count > 0)
                        {
                            shippingOptionsToBind.AddRange(shippingOptions);

                            if (shippingOptions.Count > 1 && shippingOptions.Any(so => so.Price > 0))
                            {
                                model.IsHospitalPartnerEvent = false;
                            }
                        }
                    }
                    else
                    {
                        var onlineShippingOption = _shippingOptionRepository.GetOnlineShippingOption();
                        shippingOptionsToBind.Add(onlineShippingOption);

                        if (shippingOptions != null && shippingOptions.Count > 0)
                        {
                            shippingOptionsToBind.AddRange(shippingOptions);
                        }
                    }

                    model.EventType = EventType.Retail;
                }
                else if (theEvent.EventType == EventType.Corporate)
                {
                    var onlineShippingOption = _shippingOptionRepository.GetOnlineShippingOption();
                    shippingOptionsToBind.Add(onlineShippingOption);

                    shippingOptions = _shippingOptionRepository.GetAllShippingOptionForCorporate(theEvent.AccountId.HasValue ? theEvent.AccountId.Value : 0);
                    if (shippingOptions != null && shippingOptions.Count > 0)
                    {
                        shippingOptionsToBind.AddRange(shippingOptions);
                    }
                    else
                    {
                        tempCart.ShippingId = onlineShippingOption.Id;
                    }

                    model.EventType = EventType.Corporate;
                    if (shippingOptionsToBind.Any(so => so.Id > 0))
                    {
                        shippingOptionsToBind.RemoveAll(so => so.Id == 0);
                    }
                }

                model.AllShippingOptions = Mapper.Map <IEnumerable <ShippingOption>, IEnumerable <ShippingOptionOrderItemViewModel> >(shippingOptionsToBind);
            }

            return(model);
        }