public EventCustomerBrifListModel GetList(EventCustomerListFilter filter)
        {
            var model = _eventCustomerReportingService.GetEventCustomerBriefList(filter.EventId, filter);

            if (model == null)
            {
                return(null);
            }

            var products        = _productRepository.GetAllProductsForEvent(filter.EventId);
            var shippingOptions = _shippingOptionRepository.GetAllShippingOptionsForBuyingProcess();

            var shippingOptionsToBind = new List <ShippingOption>();

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

                if (shippingOptions != null && shippingOptions.Count > 0)
                {
                    shippingOptions.RemoveAll(so => so.Price == 0);
                    shippingOptionsToBind.AddRange(shippingOptions);
                }
            }
            else if (model.EventType == EventType.Corporate)
            {
                var onlineShippingOption = _shippingOptionRepository.GetOnlineShippingOption();
                shippingOptionsToBind.Add(onlineShippingOption);

                shippingOptions = _shippingOptionRepository.GetAllShippingOptionForCorporate(model.AccountId.HasValue ? model.AccountId.Value : 0);
                if (shippingOptions != null && shippingOptions.Count > 0)
                {
                    shippingOptionsToBind.AddRange(shippingOptions);
                }
            }
            model.ShippingOptions = shippingOptionsToBind;
            model.Products        = products != null?products.OrderBy(d => d.Price).ToList() : null;

            return(model);
        }
        public PatientWorksheet GetPatientWorksheetModel(Customer customer, Event theEvent, EventCustomer eventCustomer)
        {
            var customerId = customer.Id;
            var eventId    = theEvent.Id;

            var order                = _orderRepository.GetOrderByEventCustomerId(eventCustomer.Id);
            var eventPackage         = _eventPackageRepository.GetPackageForOrder(order.Id);
            var eventTest            = _eventTestRepository.GetTestsForOrder(order.Id);
            var products             = _electronicProductRepository.GetAllProductsForEvent(eventId);
            var purchasedProduct     = _electronicProductRepository.GetElectronicProductByOrderId(order.Id);
            var customerIcdCodes     = _customerIcdCodesRepository.GetIcdByCustomerId(customerId);
            var customerTags         = _corporateCustomerCustomTagRepository.GetByCustomerId(customerId);
            var preApporvedTestNames = _preApprovedTestRepository.GetPreApprovedTestNameByEventCustomerId(eventCustomer.Id);
            var testForTechnician    = _eventTestRepository.GetTestsForEventByRole(eventId, (long)Roles.Technician);

            string[] customerRecentTags = null;

            var isCorporateEvent = theEvent.EventType == EventType.Corporate;

            if (customerTags != null && customerTags.Any() && isCorporateEvent)
            {
                customerTags       = customerTags.OrderByDescending(x => x.DataRecorderMetaData.DateCreated).Take(4);
                customerRecentTags = customerTags.Select(x => x.Tag).ToArray();
            }

            var icdCodes = new List <string>();

            if (!customerIcdCodes.IsNullOrEmpty())
            {
                icdCodes = _icdCodesRepository.GetIcdByIds(customerIcdCodes.Select(x => x.IcdCodeId)).Select(x => x.CodeName.ToUpper()).ToList();
            }

            var labName = string.Empty;

            if (customer.LabId.HasValue)
            {
                var lab = _labRepository.GetById(customer.LabId.Value);
                labName = lab.Name;
            }

            return(new PatientWorksheet
            {
                Name = customer.Name,
                CustomerId = customer.CustomerId,
                Dob = customer.DateOfBirth,
                Height = customer.Height,
                Weight = customer.Weight,
                Gender = customer.Gender,
                Package = eventPackage,
                Tests = eventTest,
                Lab = labName,
                AlaCarteTest = testForTechnician,
                AllProducts = products,
                ProductId = purchasedProduct != null ? purchasedProduct.Id : 0,
                IcdCodes = icdCodes,
                PreApporvedTestNames = preApporvedTestNames,
                EventDate = theEvent.EventDate,
                CustomTags = customerRecentTags,
                IsCorporateEvent = theEvent.EventType == EventType.Corporate
            });
        }
        public OrderPlaceEditModel GetEventPackage(OrderPlaceEditModel model, long eventId, Roles role, long customerId, TempCart tempCart)
        {
            var theEvent       = _eventRepository.GetById(eventId);
            var userGender     = !string.IsNullOrEmpty(tempCart.Gender) ? ((long)(Gender)Enum.Parse(typeof(Gender), tempCart.Gender, true)) : (long)Gender.Unspecified;
            var enableAlaCarte = Convert.ToBoolean(_configurationRepository.GetConfigurationValue(ConfigurationSettingName.EnableAlaCarte));

            var parentRole = (Roles)GetParentRoleIdByRoleId((long)role);

            if (enableAlaCarte)
            {
                if (role == Roles.Customer || parentRole == Roles.Customer)
                {
                    enableAlaCarte = theEvent.EnableAlaCarteOnline;
                }
                else if (role == Roles.CallCenterRep || role == Roles.CallCenterManager || parentRole == Roles.CallCenterRep || parentRole == Roles.CallCenterManager)
                {
                    enableAlaCarte = theEvent.EnableAlaCarteCallCenter;
                }
                else if (role == Roles.Technician || parentRole == Roles.Technician)
                {
                    enableAlaCarte = theEvent.EnableAlaCarteTechnician;
                }
                else if (!(theEvent.EnableAlaCarteOnline || theEvent.EnableAlaCarteCallCenter || theEvent.EnableAlaCarteTechnician))
                {
                    enableAlaCarte = false;
                }
            }

            var eventPackages = _eventPackageRepository.GetPackagesForEventByRole(eventId, (long)role, userGender);

            var eventTests = enableAlaCarte ? _eventTestRepository.GetTestsForEventByRole(eventId, (long)role, userGender) : null;

            if (eventTests != null && eventTests.Count() > 0)
            {
                eventTests = eventTests.Where(et => et.Test.ShowInAlaCarte).Select(et => et).ToArray();
            }
            var products        = _productRepository.GetAllProductsForEvent(eventId);
            var shippingOptions = _shippingOptionRepository.GetAllShippingOptionsForBuyingProcess();

            var shippingOptionsToBind = new List <ShippingOption>();

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

                if (shippingOptions != null && shippingOptions.Count > 0)
                {
                    shippingOptions.RemoveAll(so => so.Price == 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 (theEvent.EventType == EventType.Corporate)
            {
                eventPackages = eventPackages != null?eventPackages.OrderByDescending(d => d.Price).ThenBy(d => d.Package.RelativeOrder) : null;
            }
            else
            {
                eventPackages = eventPackages != null?eventPackages.OrderByDescending(d => d.Price) : null;
            }

            eventTests = eventTests != null?eventTests.OrderByDescending(d => d.Price) : null;

            products = products != null?products.OrderBy(d => d.Price).ToList() : null;


            model.AllEventPackages   = Mapper.Map <IEnumerable <EventPackage>, IEnumerable <EventPackageOrderItemViewModel> >(eventPackages);
            model.AllEventTests      = Mapper.Map <IEnumerable <EventTest>, IEnumerable <EventTestOrderItemViewModel> >(eventTests);
            model.AllProducts        = Mapper.Map <IEnumerable <ElectronicProduct>, IEnumerable <ProductOrderItemViewModel> >(products);
            model.AllShippingOptions = Mapper.Map <IEnumerable <ShippingOption>, IEnumerable <ShippingOptionOrderItemViewModel> >(shippingOptionsToBind);

            int age = 0;

            if (customerId > 0)
            {
                var customer = _customerRepository.GetCustomer(customerId);
                age = customer.DateOfBirth.HasValue ? customer.DateOfBirth.Value.GetAge() : 0;
            }
            else if (tempCart.Dob.HasValue)
            {
                age = tempCart.Dob.Value.GetAge();
            }

            if (age > 0)
            {
                foreach (var eventPackage in model.AllEventPackages)
                {
                    foreach (var test in eventPackage.Tests)
                    {
                        if (test.MinAge > 0 && age < test.MinAge)
                        {
                            eventPackage.NotAvailable           = true;
                            eventPackage.NotAvailabilityMessage = "includes " + test.Name + " for which minimum age required is " + test.MinAge;
                            break;
                        }
                        if (test.MaxAge > 0 && age > test.MaxAge)
                        {
                            eventPackage.NotAvailable           = true;
                            eventPackage.NotAvailabilityMessage = "includes " + test.Name + " for which maximum age required is " + test.MaxAge;
                            break;
                        }
                    }
                }

                foreach (var test in model.AllEventTests)
                {
                    if (test.MinAge > 0 && age < test.MinAge)
                    {
                        test.NotAvailable           = true;
                        test.NotAvailabilityMessage = "For this test minimum age required is " + test.MinAge;
                        break;
                    }
                    if (test.MaxAge > 0 && age > test.MaxAge)
                    {
                        test.NotAvailable           = true;
                        test.NotAvailabilityMessage = "For this test maximum age required is " + test.MaxAge;
                        break;
                    }
                }
            }

            if (model.AllEventPackages != null && model.AllEventPackages.Any())
            {
                EventPackageOrderItemViewModel package = null;
                Gender gender;
                Enum.TryParse(tempCart.Gender, out gender);

                package = EventPackageOrderItemViewModel(model.AllEventPackages, eventPackages, gender);

                foreach (var eventPackage in model.AllEventPackages)
                {
                    eventPackage.IsRecommended = eventPackage.PackageId == package.PackageId;
                }
            }

            LoadPackageImagePath(eventPackages, model.AllEventPackages);

            model.EnableImageUpsell = IsImageUpsellEnabled(eventId);

            return(model);
        }
Esempio n. 4
0
        public OnlineProductShippingEditModel GetShippingOption(TempCart tempCart)
        {
            var model = new OnlineProductShippingEditModel();

            if (tempCart.EventId != null)
            {
                var theEvent        = _eventRepository.GetById(tempCart.EventId.Value);
                var products        = _electronicProductRepository.GetAllProductsForEvent(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)
                        {
                            // shippingOptions.RemoveAll(so => so.Price == 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);
                    }
                }

                products = products != null?products.OrderBy(d => d.Price).ToList() : null;

                model.EnableImageUpsell  = IsImageUpsellEnabled(tempCart.EventId.Value);
                model.AllShippingOptions = Mapper.Map <IEnumerable <ShippingOption>, IEnumerable <ShippingOptionOrderItemViewModel> >(shippingOptionsToBind);
                model.AllProducts        = Mapper.Map <IEnumerable <ElectronicProduct>, IEnumerable <ProductOrderItemViewModel> >(products);
            }

            return(model);
        }