示例#1
0
        private void UpdateEnterprise(EnterpriseModel enterprise)
        {
            var culture        = MvcApplication.GetCurrentCulture();
            var nativeLanguage = Monscierge.Utilities.Translation.GetLanguageFromCulture(culture);

            if (enterprise != null)
            {
                Rp.ExecuteAction(() =>
                {
                    var dbEnterprise = (from e in ProxylessContext.Enterprises.Where(e2 => e2.IsActive)
                                        where e.PKID == enterprise.PKID
                                        select e).FirstOrDefault();

                    if (dbEnterprise != null)
                    {
                        if (dbEnterprise.DescriptionLanguage.Equals(nativeLanguage, StringComparison.InvariantCultureIgnoreCase))
                        {
                            dbEnterprise.Description = enterprise.Description;
                        }
                        else
                        {
                            dbEnterprise.LocalizedDescription =
                                Localization.SetLocalizedText(dbEnterprise.LocalizedDescription, nativeLanguage,
                                                              enterprise.Description);
                        }
                        dbEnterprise.FacebookUrl = enterprise.FacebookUrl;
                        dbEnterprise.Name        = enterprise.Name;
                        dbEnterprise.TwitterUrl  = enterprise.TwitterUrl;
                        dbEnterprise.URL         = enterprise.WebsiteUrl;
                    }
                });
            }
        }
示例#2
0
        public JsonNetResult GetSupportedCultures()
        {
            var language = MvcApplication.GetCurrentCulture();
            var cultures = new List <CultureViewModel>
            {
                new CultureViewModel()
                {
                    Key = "EN", Culture = "en-US", Name = @ConnectCMSResources.English, NativeName = "English", IsActive = true
                },
                new CultureViewModel()
                {
                    Key = "FR", Culture = "fr-FR", Name = @ConnectCMSResources.French, NativeName = "Français", IsActive = true
                }
            };

            return(JsonNet(cultures.OrderByDescending(x => x.Key == language)));
        }
示例#3
0
        public EnterpriseModel GetEnterpriseForEdit(int deviceId, int enterpriseId, int?enterpriseLocationId,
                                                    float?hotelLatitude, float?hotelLongitude, float radiusInMeters)
        {
            EnterpriseModel enterprise = null;

            var hotelPoint = GeographyUtils.GetPointFromLatitudeAndLongitude(hotelLatitude, hotelLongitude);

            if (hotelPoint != null)
            {
                RootRepository.SecurityRepository.AssertDevicePermissions(deviceId);

                // TODO: JD: Culture.
                var culture = MvcApplication.GetCurrentCulture();

                var nativeLanguage = culture.Substring(0, 2).ToUpper();

                var item =
                    Rp.ExecuteAction(
                        () => (from e in ProxylessContext.Enterprises.Where(e2 => e2.IsActive && e2.PKID == enterpriseId)
                               let eim = e.EnterpriseImageMaps.Where(eim2 => eim2.IsActive)
                                         let el = e.EnterpriseLocations.Where(el2 => el2.IsActive && (!enterpriseLocationId.HasValue || el2.PKID == enterpriseLocationId.Value))
                                                  let ecm = e.EnterpriseCategoryMaps
                                                            let fecm = ecm.FirstOrDefault()
                                                                       let cm = ecm.Where(ecm2 => ecm2.CategoryMap.IsActive).Select(ecm2 => ecm2.CategoryMap)
                                                                                let fcm = cm.FirstOrDefault()
                                                                                          let hcm = cm.SelectMany(cm2 => cm2.HotelCategoryMaps.Where(hcm2 => hcm2.IsActive && hcm2.FKDevice == deviceId))
                                                                                                    let fhcm = hcm.OrderBy(hcm2 => hcm2.Ordinal).FirstOrDefault()
                                                                                                               let hboem = ecm.SelectMany(ecm2 => ecm2.HotelBestOfEnterpriseMaps.Where(hboem2 => hboem2.IsActive && hboem2.FKDevice == deviceId).OrderBy(hboem2 => hboem2.Ordinal))
                                                                                                                           let hboelm = hboem.SelectMany(hboem2 => hboem2.HotelBestOfEnterpriseLocationMaps)
                                                                                                                                        select new
                {
                    CMImage = fcm.Image,
                    ECMImage = fecm.Image,
                    Enterprise = new EnterpriseModel
                    {
                        EnterpriseLocations = (from el2 in el
                                               let c = ProxylessContext.Countries.FirstOrDefault(c2 => c2.IsActive && c2.ISOCountryCode == el2.Country)
                                                       let s =
                                                   ProxylessContext.States.FirstOrDefault(
                                                       s2 => s2.IsActive && s2.ISOStateCode == el2.State && s2.FKCountry == c.PKID)
                                                   select new EnterpriseLocationModel
                        {
                            BingId = el2.BingId,
                            DistanceInMeters = el2.Coordinates.Distance(hotelPoint),
                            HourType = el2.HourType,
                            LocalHours = el2.Hours,
                            LocalHoursLanguage = !string.IsNullOrEmpty(el2.HoursLanguage) ? el2.HoursLanguage : nativeLanguage,
                            LocalHoursXml = el2.LocalizedHours,
                            Location = new LocationModel
                            {
                                Address1 = el2.Address1,
                                Address2 = el2.Address2,
                                City = el2.City,
                                Country = c,
                                Latitude = el2.Latitude,
                                Longitude = el2.Longitude,
                                PostalCode = el2.PostalCode,
                                State = s
                            },
                            Phone = el2.Phone,
                            PhoneISOCountryCode = el2.PhoneISOCountryCode,
                            PKID = el2.PKID,
                            Recommended = hboelm.Any(hboelm2 => hboelm2.FKEnterpriseLocation == el2.PKID)
                        }),
                        LocalDescription = e.Description,
                        LocalDescriptionLanguage =
                            e.DescriptionLanguage != null && e.DescriptionLanguage != string.Empty
                                                                                                ? e.DescriptionLanguage
                                                                                                : nativeLanguage,
                        LocalDescriptionXml = e.LocalizedDescription,
                        Name = e.Name,
                        PKID = e.PKID,
                        Recommended = hboem.Any() && !hboelm.Any()
                    },
                    EnterpriseImages = eim.Select(eim2 => eim2.Image),
                    HCMImage = fhcm.Image,
                })).FirstOrDefault();

                if (item != null && item.Enterprise != null)
                {
                    if (item.EnterpriseImages != null)
                    {
                        foreach (var customImage in item.EnterpriseImages)
                        {
                            ((List <ImageModel>)item.Enterprise.Images).Add(new ImageModel(customImage));
                        }
                    }

                    if (item.CMImage != null)
                    {
                        item.Enterprise.ListItemImage = new ImageModel(item.CMImage);
                    }

                    if (item.HCMImage != null)
                    {
                        item.Enterprise.ListItemImage = new ImageModel(item.HCMImage);
                    }

                    if (item.ECMImage != null)
                    {
                        item.Enterprise.ListItemImage = new ImageModel(item.ECMImage);
                    }

                    ((List <ImageModel>)item.Enterprise.Images).Insert(0, item.Enterprise.ListItemImage);

                    item.Enterprise.Description = Localization.GetLocalizedText(item.Enterprise.LocalDescription,
                                                                                item.Enterprise.LocalDescriptionXml, item.Enterprise.LocalDescriptionLanguage, nativeLanguage);
                    item.Enterprise.EnterpriseLocations.ForEach(
                        el => el.Hours = Localization.GetLocalizedText(el.LocalHours, el.LocalHoursXml, el.LocalHoursLanguage, nativeLanguage));

                    enterprise = item.Enterprise;
                }
            }

            return(enterprise);
        }