Exemple #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="ci"></param>
        /// <param name="place"></param>
        /// <returns></returns>
        public dynamic CreateTemplateDynamicData(PartnerCall obj, CfCacheIndexEntry place)
        {
            var commentData = "";

            if (!string.IsNullOrEmpty(obj.Comment))
            {
                if (obj.Comment.Length < 255)
                {
                    commentData = obj.Comment;
                }
                else
                {
                    commentData = obj.Comment.Excerpt(255) + " ...";
                }
            }

            string level = ((ClimbingLevelGeneral)obj.PreferredLevel).ToString();

            string start = obj.StartDateTime.ToString("dd MMM HH:mm");

            if (obj.StartDateTime == obj.StartDateTime.Date)
            {
                start = obj.StartDateTime.ToString("dd MMM");
            }

            bool isLoc = (place.Type != CfType.City && place.Type != CfType.ClimbingArea);

            dynamic data = new { Place   = Sanitize(place.Name),
                                 Comment = Sanitize(commentData), Start = start, Level = level, Indoor = obj.ForIndoor, Outdoor = obj.ForOutdoor, IsLoc = isLoc };

            return(data);
        }
Exemple #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="objectCollection"></param>
        /// <returns></returns>
        public dynamic CreateTemplateDynamicData(dynamic objectCollection)
        {
            PartnerCall       ci    = objectCollection.PartnerCall;
            CfCacheIndexEntry place = objectCollection.Place;

            return(CreateTemplateDynamicData(ci, place));
        }
Exemple #3
0
        public ActionResult Edit(Guid id)
        {
            CfCacheIndexEntry place = AppLookups.GetCacheIndexEntry(id);

            if (place == null)
            {
                return(new PlacesController().PlaceNotFound());
            }
            else if (place.Type == CfType.ClimbIndoor)
            {
                return(RedirectToAction("ClimbIndoorEdit", new { id = id }));
            }
            else if (place.Type == CfType.ClimbOutdoor)
            {
                return(RedirectToAction("ClimbOutdoorEdit", new { id = id }));
            }
            else
            {
                var category = place.Type.ToPlaceCateogry();
                if (category == PlaceCategory.Area)
                {
                    return(RedirectToAction("AreaEdit", new { id = id }));
                }
                else if (category == PlaceCategory.IndoorClimbing)
                {
                    return(RedirectToAction("LocationIndoorEdit", new { id = id }));
                }
                else if (category == PlaceCategory.OutdoorClimbing)
                {
                    return(RedirectToAction("LocationOutdoorEdit", new { id = id }));
                }
                throw new Exception(string.Format("Category [{0}] from place [{1}][2] not supported by moderate edit", category, place.Name, place.IDstring));
            }
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="objectCollection"></param>
        /// <returns></returns>
        public dynamic CreateTemplateDynamicData(dynamic objectCollection)
        {
            Opinion           opinion = objectCollection.Opinion;
            CfCacheIndexEntry place   = objectCollection.Place;

            return(CreateTemplateDynamicData(opinion, place));
        }
        private ClimbListDto GetClimbsOfLocation(CfCacheIndexEntry loc, DateTime dateTime)
        {
            if (loc == null)
            {
                throw new ArgumentNullException("GetClimbsOfLocation:loc");
            }

            //-- GetCurrentClimbsOfLocation is smart enough under the hood to distinguish for indoor & outdoor
            var placeCategory = loc.Type.ToPlaceCateogry();

            if (placeCategory == PlaceCategory.IndoorClimbing ||
                placeCategory == PlaceCategory.OutdoorClimbing)
            {
                if (dateTime > DateTime.UtcNow.AddHours(-24))
                {
                    return(CfPerfCache.TryGetFromCache <ClimbListDto>("mobindoorclimblist-" + loc.ID.ToString("N"),
                                                                      () => GetClimbListDto(loc, placeCategory, dateTime), CfPerfCache.SixtyMinCacheItemPolicy));
                }
                else
                {
                    return(GetClimbListDto(loc, placeCategory, dateTime));
                }
            }
            else
            {
                throw new ArgumentNullException("Service not invoked correctly - loc not valid place for operation");
            }
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="objectCollection"></param>
        /// <returns></returns>
        public dynamic CreateTemplateDynamicData(dynamic objectCollection)
        {
            CheckIn           ci    = objectCollection.CheckIn;
            CfCacheIndexEntry place = objectCollection.Place;

            return(CreateTemplateDynamicData(ci, place));
        }
        public ActionResult Index()
        {
            var user = usrSvc.GetProfileByID(CfIdentity.UserID);

            ViewBag.User = user;

            CfCacheIndexEntry place = null;

            if (user.PlaceFavorite5.HasValue)
            {
                place = CfCacheIndex.Get(user.PlaceFavorite5.Value);
            }
            ViewBag.Place = place;

            var deducPlaces = new List <CfCacheIndexEntry>();

            if (place != null)
            {
                ViewBag.PartnerCalls = pcSvc.GetPlacesGeoDeducLatestPartnerCalls(place.ID, 25).ToList();

                if (place.Type.ToPlaceCateogry() != PlaceCategory.Area)
                {
                    deducPlaces = CfPerfCache.GetGeoDeduciblePlaces(place);
                }
            }
            ViewBag.DeducPlaces = deducPlaces;


            return(View());
        }
Exemple #8
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="objectCollection"></param>
        /// <returns></returns>
        public dynamic CreateTemplateDynamicData(dynamic objectCollection)
        {
            string            comment = objectCollection.Comment;
            CfCacheIndexEntry place   = objectCollection.Place;

            return(CreateTemplateDynamicData(comment, place));
        }
Exemple #9
0
        /// <summary>
        /// Remove item from both our remote cache and if that succeeds add to local cache too
        /// </summary>
        /// <param name="entry"></param>
        public static void Remove(CfCacheIndexEntry entry)
        {
            var key = GetKey(entry.ID);

            Level2Cache.Remove(key);
            Level1Cache.Remove(key);
        }
Exemple #10
0
        /// <summary>
        /// Add an item to our remote cache and if that succeeds add to local cache too
        /// </summary>
        /// <param name="entry"></param>
        public static void Add(CfCacheIndexEntry entry)
        {
            var key = GetKey(entry.ID);

            if (Level2Cache.Add(entry, key))
            {
                Level1Cache.Add(new CacheItem(key, entry), Level1ItemPolicy);
            }
        }
Exemple #11
0
        /// <summary>
        /// Update item in our remote cache and if that succeeds add to local cache too
        /// </summary>
        /// <param name="entry"></param>
        public static void Update(CfCacheIndexEntry entry)
        {
            var key = GetKey(entry.ID);

            if (Level2Cache.Add(entry, key)) //-- Here we can call Add because the Memcached Store takes the Set flag which causes an update
            {
                Level1Cache.Remove(key);
                Level1Cache.Add(new CacheItem(key, entry), Level1ItemPolicy);
            }
        }
        public void UnclaimObjectAuthorization(CfCacheIndexEntry obj)
        {
            var modUserID = currentUser.UserID;

            var modProfile = modProfileRepo.GetByID(modUserID);

            if (modProfile == null)
            {
                throw new AccessViolationException("UnclaimPlace: User does not have a moderator profile. User must first add content to get a moderator profile.");
            }
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="place"></param>
        /// <returns></returns>
        public dynamic CreateTemplateDynamicData(CheckIn obj, CfCacheIndexEntry place)
        {
            var commentData = "No comment";
            if (!string.IsNullOrEmpty(obj.Comment))
            {
                if (obj.Comment.Length < 255) { commentData = obj.Comment; }
                else { commentData = obj.Comment.Excerpt(255) + " ..."; }
            }

            dynamic data = new { Place = place.Name, Comment = commentData };
            return data;
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="ci"></param>
        /// <param name="obj"></param>
        /// <returns></returns>
        public dynamic CreateTemplateDynamicData(Opinion o, CfCacheIndexEntry obj)
        {
            var commentData = "No comment";
            if (!string.IsNullOrEmpty(o.Comment))
            {
                if (o.Comment.Length < 255) { commentData = o.Comment; }
                else { commentData = o.Comment.Excerpt(255) + " ..."; }
            }

            dynamic data = new { Name = Sanitize(obj.Name), Comment = Sanitize(commentData), Score = o.Rating };
            return data;
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="id"></param>
        /// <param name="userID"></param>
        /// <param name="place"></param>
        /// <param name="isPrivate"></param>
        /// <param name="data"></param>
        /// <returns></returns>
        public virtual Post CreatePost(Guid id, Guid userID, CfCacheIndexEntry place, bool isPublic, dynamic data)
        {
            if (data == null) { throw new ArgumentNullException("Cannot create template with null dynamic data"); }

            var post = new Post(id, userID, place.ID, place.TypeID, isPublic);
            post.TypeID = PostTypeID;
            post.TemplateKey = TemplateKey;
            post.TemplateData = GetDataJson(data);
            post.SlugUrlPart = GetPostSlugUrlPart(id, place);
            post.LastActivityUtc = DateTime.UtcNow;

            return Create(post);
        }
        public static string ShortestName(this CfCacheIndexEntry o)
        {
            string name = string.Empty;

            if (o != null)
            {
                name = o.Name;
                if (!string.IsNullOrEmpty(o.NameShort))
                {
                    name = o.NameShort;
                }
            }
            return(name);
        }
 public PartnerCallSubscriptionDto(CfCacheIndexEntry p, PartnerCallSubscription s)
 {
     ID         = s.ID.ToString("N");
     PlaceID    = p.ID.ToString("N");
     Type       = (byte)p.Type;
     Country    = p.CountryID;
     Flag       = cf.Caching.AppLookups.CountryFlag(p.CountryID);
     Name       = p.Name;
     Indoor     = s.ForIndoor;
     Outdoor    = s.ForOutdoor;
     Email      = s.EmailRealTime;
     Mobile     = s.MobileRealTime;
     ExactMatch = s.ExactMatchOnly;
 }
        private ClimbListDto GetClimbListDto(CfCacheIndexEntry loc, PlaceCategory placeCategory, DateTime dateTime)
        {
            var dto         = new ClimbListDto();
            var climbsOfLoc = geoSvc.GetClimbsOfLocationForLogging(loc.ID, dateTime);

            if (placeCategory == PlaceCategory.IndoorClimbing)
            {
                dto.Sections = new List <ClimbSectionDto>();
                foreach (var s in geoSvc.GetLocationSections(loc.ID))
                {
                    var climbsInSectionOrdered = (from c in climbsOfLoc orderby c.GradeCfNormalize where c.SectionID == s.ID select new ClimbListItemDto(c)).ToList();
                    var range = "";
                    if (climbsInSectionOrdered.Count > 0)
                    {
                        range = string.Format("{0} - {1}", climbsInSectionOrdered.First().Grade, climbsInSectionOrdered.Last().Grade);
                    }

                    dto.Sections.Add(new ClimbSectionDto()
                    {
                        ID     = s.ID.ToString("N"),
                        Name   = s.Name,
                        Type   = s.DefaultClimbTypeID.ToString(),
                        Range  = range,
                        Avatar = s.Avatar ?? "4d62a66f-62f.jpg",
                        Climbs = climbsInSectionOrdered
                    });
                }
            }

            var uncategorized = from c in climbsOfLoc.Where(c => !c.SectionID.HasValue) select new ClimbListItemDto(c);

            if (uncategorized.Count() > 0)
            {
                dto.Sections.Add(new ClimbSectionDto()
                {
                    ID     = Guid.Empty.ToString("N"),
                    Name   = "Uncategorized",
                    Climbs = uncategorized.ToList()
                });
            }

            return(dto);
        }
Exemple #19
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="place"></param>
        /// <returns></returns>
        public dynamic CreateTemplateDynamicData(CheckIn obj, CfCacheIndexEntry place)
        {
            var commentData = "No comment";

            if (!string.IsNullOrEmpty(obj.Comment))
            {
                if (obj.Comment.Length < 255)
                {
                    commentData = obj.Comment;
                }
                else
                {
                    commentData = obj.Comment.Substring(0, 254) + " ...";
                }
            }

            string mediaList = " ";

            if (obj.Media.Count > 0)
            {
                mediaList = ""; foreach (var m in obj.Media)
                {
                    mediaList += m.ThumbUrl().Replace(Stgs.ImgsRt, "") + ",";
                }
            }

            string climbsList = " ";

            if (obj.LoggedClimbs.Count > 0)
            {
                climbsList = ""; foreach (var m in obj.LoggedClimbs.OrderBy(l => l.Utc))
                {
                    climbsList += string.Format("{0}|{1}|{2},", m.Outcome, m.Experince, SantitizeClimbName(m.ClimbName));
                }
            }

            dynamic data = new { Place   = base.Sanitize(place.Name),
                                 Comment = base.Sanitize(commentData),
                                 Media   = mediaList.Substring(0, mediaList.Length - 1),
                                 Climbs  = climbsList.Substring(0, climbsList.Length - 1) };

            return(data);
        }
        public CheckIn GetVisitByLocationAndUtc(CfCacheIndexEntry loc, DateTime loggedClimbUtc)
        {
            var startDate = loggedClimbUtc.AddHours(-7); //-- We go backwards incase they quick logged...
            var endDate   = loggedClimbUtc.AddHours(7);

            var visit = checkInRepo.GetAll().Where(ci => ci.LocationID == loc.ID &&
                                                   ci.Utc > startDate && ci.Utc < endDate && ci.UserID == CfIdentity.UserID).SingleOrDefault();

            //-- First climb we've logged for the visit
            if (visit == default(CheckIn))
            {
                visit = CreateCheckIn(new CheckIn()
                {
                    Utc = loggedClimbUtc.AddMinutes(-10), LocationID = loc.ID, Comment =
                        string.Format("I'm at {0} logging climbs!", loc.Name), IsPrivate = false
                });
            }

            return(visit);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="place"></param>
        /// <returns></returns>
        public dynamic CreateTemplateDynamicData(CheckIn obj, CfCacheIndexEntry place)
        {
            var commentData = "No comment";

            if (!string.IsNullOrEmpty(obj.Comment))
            {
                if (obj.Comment.Length < 255)
                {
                    commentData = obj.Comment;
                }
                else
                {
                    commentData = obj.Comment.Excerpt(255) + " ...";
                }
            }

            dynamic data = new { Place = place.Name, Comment = commentData };

            return(data);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="ci"></param>
        /// <param name="obj"></param>
        /// <returns></returns>
        public dynamic CreateTemplateDynamicData(Opinion o, CfCacheIndexEntry obj)
        {
            var commentData = "No comment";

            if (!string.IsNullOrEmpty(o.Comment))
            {
                if (o.Comment.Length < 255)
                {
                    commentData = o.Comment;
                }
                else
                {
                    commentData = o.Comment.Excerpt(255) + " ...";
                }
            }

            dynamic data = new { Name = Sanitize(obj.Name), Comment = Sanitize(commentData), Score = o.Rating };

            return(data);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="ci"></param>
        /// <param name="place"></param>
        /// <returns></returns>
        public dynamic CreateTemplateDynamicData(PartnerCall obj, CfCacheIndexEntry place)
        {
            var commentData = "";
            if (!string.IsNullOrEmpty(obj.Comment))
            {
                if (obj.Comment.Length < 255) { commentData = obj.Comment; }
                else { commentData = obj.Comment.Excerpt(255) + " ..."; }
            }

            string level = ((ClimbingLevelGeneral)obj.PreferredLevel).ToString();

            string start = obj.StartDateTime.ToString("dd MMM HH:mm");
            if (obj.StartDateTime == obj.StartDateTime.Date) { start = obj.StartDateTime.ToString("dd MMM"); }

            bool isLoc = (place.Type != CfType.City && place.Type != CfType.ClimbingArea);

            dynamic data = new { Place = Sanitize(place.Name),
                Comment = Sanitize(commentData), Start = start, Level = level, Indoor = obj.ForIndoor, Outdoor = obj.ForOutdoor, IsLoc = isLoc };
            return data;
        }
 public PartnerCallDto(CfCacheIndexEntry p, PartnerCall pc, IUserBasicDetail user)
 {
     ID = pc.ID.ToString("N");
     PlaceID = p.ID.ToString("N");
     Type = (byte)p.Type;
     Country = p.CountryID;
     PlaceName = p.Name;
     Indoor = pc.ForIndoor;
     Outdoor = pc.ForOutdoor;
     CreatedUtc = pc.CreatedUtc.ToEpochTimeString();
     StartDateTime = pc.StartDateTime.ToString("h:mm tt ddd MMM dd");
     if (!pc.HasDefaultEndDate)
     {
         EndDateTime = pc.EndDateTime.ToString("h:mm tt ddd MMM dd");
     }
     PerferredLevel = pc.PreferredLevel;
     Comment = pc.Comment;
     ByID = user.ID.ToString("N");
     By = user.DisplayName;
     ByPic = user.Avatar;
 }
Exemple #25
0
        public PostDto(PostRendered p, CfCacheIndexEntry place, string by, string byPic)
        {
            ID        = p.ID.ToString("N");
            PlaceID   = p.PlaceID.ToString("N");
            Type      = p.TypeID;
            PlaceName = place.Name;
            CountryID = place.CountryID;
            Utc       = p.Utc.ToEpochTimeString();
            By        = by;
            ByID      = p.UserID.ToString("N");
            ByPic     = byPic;
            if (p.Content.Contains("<split>"))
            {
                var split = p.Content.IndexOf("<split>");
                Meta    = p.Content.Substring(0, split);
                Comment = p.Content.Substring(split + 7, p.Content.Length - (split + 7));
            }

            //Content = p.Content;
            Comments = new List <PostCommentDto>();
        }
 public PartnerCallDto(CfCacheIndexEntry p, PartnerCall pc, IUserBasicDetail user)
 {
     ID            = pc.ID.ToString("N");
     PlaceID       = p.ID.ToString("N");
     Type          = (byte)p.Type;
     Country       = p.CountryID;
     PlaceName     = p.Name;
     Indoor        = pc.ForIndoor;
     Outdoor       = pc.ForOutdoor;
     CreatedUtc    = pc.CreatedUtc.ToEpochTimeString();
     StartDateTime = pc.StartDateTime.ToString("h:mm tt ddd MMM dd");
     if (!pc.HasDefaultEndDate)
     {
         EndDateTime = pc.EndDateTime.ToString("h:mm tt ddd MMM dd");
     }
     PerferredLevel = pc.PreferredLevel;
     Comment        = pc.Comment;
     ByID           = user.ID.ToString("N");
     By             = user.DisplayName;
     ByPic          = user.Avatar;
 }
Exemple #27
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="objectCollection"></param>
        /// <returns></returns>
        public dynamic CreateTemplateDynamicData(dynamic objectCollection)
        {
            CfCacheIndexEntry content = objectCollection.Content;

            return(CreateTemplateDynamicData(content));
        }
        //protected static CfCacheIndex CI { get; set; }

        /// <summary>
        /// Static constructor to force some caching to occur on application load
        /// </summary>
        //public static void InitializeAllCacheItems()
        //{
        //    CPC
        //}

        public static void AddIndexEntryToCache(CfCacheIndexEntry entry)
        {
            CfCacheIndex.Add(entry);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="obj"></param>
        public void UnclaimObject(CfCacheIndexEntry obj)
        {
            UnclaimObjectAuthorization(obj);

            objModMetaRepo.UnclaimObject(obj, currentUser.UserID);
        }
 public static void UpdateIndexEntryInCache(CfCacheIndexEntry entry)
 {
     CfCacheIndex.Update(entry);
 }
        private NewPartnerCallViewModel PrepareNewCallViewData(CfCacheIndexEntry place)
        {
            var m = new NewPartnerCallViewModel()
            {
                ParnterCallPlaceID = place.ID, ForIndoor = true, ForOutdoor = true
            };

            if (place.Type == CfType.Country)
            {
                ViewBag.PlaceDisallowed = true;
                ViewBag.Place           = place;
            }
            else if (place.Type == CfType.Province)
            {
                var area = geoSvc.GetAreaByID(place.ID);

                ViewBag.PlaceDisallowed = true;
                ViewBag.Place           = place;

                ViewBag.InterectingAreas = geoSvc.GetIntersectingAreas(area).Where(a => a.Type != CfType.Province &&
                                                                                   !a.DisallowPartnerCalls).ToList();
            }
            else if (place.Type.ToPlaceCateogry() == PlaceCategory.Area)
            {
                ViewBag.PlaceType = "Area";
                var area = geoSvc.GetAreaByID(place.ID);
                ViewBag.Place = area;

                if (area.DisallowPartnerCalls)
                {
                    ViewBag.PlaceDisallowed = true;
                }
                else
                {
                    var geoJsonUrl = Stgs.MapSvcRelativeUrl + "area/" + place.ID.ToString();

                    var mapModel = new Bing7GeoJsonMapViewModel("climbing-map-" + place.ID, 680, 400, geoJsonUrl);
                    mapModel.ViewOptions = new Bing7MapViewOptionsViewModel(mappingSvc.GetBingViewByID(area.ID));
                    var mapItems = new MappingService().GetAreaEditMapItems(area);
                    ViewBag.MapItemsArea = mapItems.Items[0];
                    mapItems.Items.RemoveAt(0);
                    ViewBag.MapItemsLocations = mapItems.Items;
                    ViewBag.MapModel          = mapModel;
                }

                ViewBag.ChildLocations = geoSvc.GetGeoDeduciblePlaces(place).Where(p => p.Type.IsLocation());

                ViewBag.InterectingAreas = geoSvc.GetIntersectingAreas(area).Where(a => a.Type != CfType.Province &&
                                                                                   !a.DisallowPartnerCalls).ToList();
            }
            else if (place.Type.ToPlaceCateogry() == PlaceCategory.IndoorClimbing ||
                     place.Type.ToPlaceCateogry() == PlaceCategory.OutdoorClimbing)
            {
                ViewBag.PlaceType = "Location";
                var location = geoSvc.GetLocationByID(place.ID);
                ViewBag.Place = location;

                if (location.IsIndoorClimbing)
                {
                    m.ForOutdoor = false;
                }
                if (location.IsOutdoorClimbing)
                {
                    m.ForIndoor = false;
                }

                var mapModel = new Bing7MapWithLocationViewModel(location.NameUrlPart, 732, 340, location.Latitude,
                                                                 location.Longitude, location.AvatarRelativeUrl);

                var mapViewSettings = mappingSvc.GetBingViewByID(location.ID);
                if (mapViewSettings == default(PlaceBingMapView))
                {
                    mapViewSettings = PlaceBingMapView.GetDefaultIndoorSettings(location);
                }
                mapModel.ViewOptions    = new Bing7MapViewOptionsViewModel(mapViewSettings);
                ViewBag.LocationMapView = mapModel;

                ViewBag.InterectingAreas = geoSvc.GetIntersectingAreasOfPoint(location.Latitude, location.Longitude)
                                           .Where(a => a.Type != CfType.Province && !a.DisallowPartnerCalls).ToList();
            }
            else
            {
                throw new ArgumentException("Place type [" + place.Type.ToString() + "] not supported for partner calls");
            }

            return(m);
        }
        public CheckIn GetVisitByLocationAndUtc(CfCacheIndexEntry loc, DateTime loggedClimbUtc)
        {
            var startDate = loggedClimbUtc.AddHours(-7); //-- We go backwards incase they quick logged...
            var endDate = loggedClimbUtc.AddHours(7);

            var visit = checkInRepo.GetAll().Where( ci => ci.LocationID == loc.ID &&
                ci.Utc > startDate && ci.Utc < endDate && ci.UserID == CfIdentity.UserID).SingleOrDefault();

            //-- First climb we've logged for the visit
            if (visit == default(CheckIn)) {
                visit = CreateCheckIn( new CheckIn() { Utc = loggedClimbUtc.AddMinutes(-10), LocationID = loc.ID, Comment =
                    string.Format("I'm at {0} logging climbs!", loc.Name), IsPrivate = false });
            }

            return visit;
        }
 //protected static CfCacheIndex CI { get; set; }
 /// <summary>
 /// Static constructor to force some caching to occur on application load
 /// </summary>
 //public static void InitializeAllCacheItems()
 //{
 //    CPC
 //}
 public static void AddIndexEntryToCache(CfCacheIndexEntry entry)
 {
     CfCacheIndex.Add(entry);
 }
 public static void UpdateIndexEntryInCache(CfCacheIndexEntry entry)
 {
     CfCacheIndex.Update(entry);
 }
 /// <summary>
 /// 
 /// </summary>
 /// <param name="obj"></param>
 /// <param name="content"></param>
 /// <returns></returns>
 public dynamic CreateTemplateDynamicData(CfCacheIndexEntry content)
 {
     dynamic data = new { Content = Sanitize(content.Name), Category = content.Type.ToPlaceCateogry() };
     return data;
 }
Exemple #36
0
        public static void SendPartnerCallEmail(IUserBasicDetail to, IUserBasicDetail by, CfCacheIndexEntry place,
                                                PartnerCall pc, string matchingSubscriptionPlaces)
        {
            string toEmail = to.Email;

            SMTP.PostSingleMail(new cfEmail(
                                    string.Format("{0}'s PartnerCall for {1}", by.FullName, place.Name),
                                    HtmlBodyGenerator.GetPartnerCallBody(pc.ID, by.ID, "climber/" + by.ID, by.FullName,
                                                                         place.SlugUrl, place.Name, pc.StartDateTime, by.Avatar, pc.Comment, matchingSubscriptionPlaces),
                                    new MailAddress(toEmail, to.FullName), Stgs.MailMan));
        }
 /// <summary>
 /// 
 /// </summary>
 /// <param name="id"></param>
 /// <param name="place"></param>
 /// <returns></returns>
 public string GetPostSlugUrlPart(Guid id, CfCacheIndexEntry place)
 {
     // e.g. "checkin-{0}-{1:MMdd}{2}"
     return string.Format(PostSlugFormat, place.NameUrlPart, DateTime.Now, id.ToString().Substring(0,8));
 }
Exemple #38
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="ci"></param>
        /// <param name="place"></param>
        /// <returns></returns>
        public dynamic CreateTemplateDynamicData(string comment, CfCacheIndexEntry place)
        {
            dynamic data = new { Place = Sanitize(place.Name), Comment = Sanitize(comment) };

            return(data);
        }
        private NewPartnerCallViewModel PrepareNewCallViewData(CfCacheIndexEntry place)
        {
            var m = new NewPartnerCallViewModel() { ParnterCallPlaceID = place.ID, ForIndoor = true, ForOutdoor = true };

            if (place.Type == CfType.Country)
            {
                ViewBag.PlaceDisallowed = true;
                ViewBag.Place = place;
            }
            else if (place.Type == CfType.Province)
            {
                var area = geoSvc.GetAreaByID(place.ID);

                ViewBag.PlaceDisallowed = true;
                ViewBag.Place = place;

                ViewBag.InterectingAreas = geoSvc.GetIntersectingAreas(area).Where(a => a.Type != CfType.Province
                    && !a.DisallowPartnerCalls).ToList();
            }
            else if (place.Type.ToPlaceCateogry() == PlaceCategory.Area)
            {
                ViewBag.PlaceType = "Area";
                var area = geoSvc.GetAreaByID(place.ID);
                ViewBag.Place = area;

                if (area.DisallowPartnerCalls) { ViewBag.PlaceDisallowed = true; }
                else
                {
                    var geoJsonUrl = Stgs.MapSvcRelativeUrl + "area/" + place.ID.ToString();

                    var mapModel = new Bing7GeoJsonMapViewModel("climbing-map-" + place.ID, 680, 400, geoJsonUrl);
                    mapModel.ViewOptions = new Bing7MapViewOptionsViewModel(mappingSvc.GetBingViewByID(area.ID));
                    var mapItems = new MappingService().GetAreaEditMapItems(area);
                    ViewBag.MapItemsArea = mapItems.Items[0];
                    mapItems.Items.RemoveAt(0);
                    ViewBag.MapItemsLocations = mapItems.Items;
                    ViewBag.MapModel = mapModel;
                }

                ViewBag.ChildLocations = geoSvc.GetGeoDeduciblePlaces(place).Where(p=>p.Type.IsLocation());

                ViewBag.InterectingAreas = geoSvc.GetIntersectingAreas(area).Where(a => a.Type != CfType.Province
                    && !a.DisallowPartnerCalls).ToList();
            }
            else if (place.Type.ToPlaceCateogry() == PlaceCategory.IndoorClimbing
                || place.Type.ToPlaceCateogry() == PlaceCategory.OutdoorClimbing)
            {
                ViewBag.PlaceType = "Location";
                var location = geoSvc.GetLocationByID(place.ID);
                ViewBag.Place = location;

                if (location.IsIndoorClimbing) { m.ForOutdoor = false; }
                if (location.IsOutdoorClimbing) { m.ForIndoor = false; }

                var mapModel = new Bing7MapWithLocationViewModel(location.NameUrlPart, 732, 340, location.Latitude,
                    location.Longitude, location.AvatarRelativeUrl);

                var mapViewSettings = mappingSvc.GetBingViewByID(location.ID);
                if (mapViewSettings == default(PlaceBingMapView)) { mapViewSettings = PlaceBingMapView.GetDefaultIndoorSettings(location); }
                mapModel.ViewOptions = new Bing7MapViewOptionsViewModel(mapViewSettings);
                ViewBag.LocationMapView = mapModel;

                ViewBag.InterectingAreas = geoSvc.GetIntersectingAreasOfPoint(location.Latitude, location.Longitude)
                    .Where(a => a.Type != CfType.Province && !a.DisallowPartnerCalls).ToList();
            }
            else
            {
                throw new ArgumentException("Place type [" + place.Type.ToString() + "] not supported for partner calls");
            }

            return m;
        }