コード例 #1
0
        public Message GetTodayPartnerCallsForPlace(string id)
        {
            try
            {
                SvcContext ctx = InflateContext(); if (ctx.Invalid)
                {
                    return(ctx.ContextMessage);
                }

                Guid pID   = Guid.ParseExact(id, "N");
                var  calls = pcSvc.GetPlacesGeoDeducTodayPartnerCalls(pID);

                var dto = new List <PartnerCallDto>();

                foreach (var c in calls)
                {
                    //-- Here we use perf cache instead of Include()/join because it's likely the user will have revisited the same place
                    var place = CfCacheIndex.Get(c.PlaceID);
                    if (place != null)
                    {
                        var user    = CfPerfCache.GetClimber(c.UserID);
                        var callDto = new PartnerCallDto(place, c, user);
                        dto.Add(callDto);
                    }
                }

                return(ReturnAsJson(dto));
            }
            catch (Exception ex)
            {
                CfTrace.Error(ex);
                return(Failed("Partner search failed : " + ex.Message));
            }
        }
コード例 #2
0
        public Message GetMyPartnerCalls()
        {
            SvcContext ctx = InflateContext(); if (ctx.Invalid)
            {
                return(ctx.ContextMessage);
            }

            var calls = pcSvc.GetUsersLatestPartnerCalls(CfIdentity.UserID, 10);
            var dto   = new List <PartnerCallDto>();

            var user = CfPerfCache.GetClimber(CfIdentity.UserID);

            foreach (var c in calls)
            {
                //-- Here we use perf cache instead of Include()/join because it's likely the user will have revisited the same place
                var place = CfCacheIndex.Get(c.PlaceID);
                if (place != null)
                {
                    var callDto = new PartnerCallDto(place, c, user);
                    dto.Add(callDto);
                }
            }

            return(ReturnAsJson(dto));
        }
コード例 #3
0
        public Message NewPartnerCall(string loc, string start, string end, string preferredLevel, string comment)
        {
            SvcContext ctx = InflateContext(); if (ctx.Invalid)

            {
                return(ctx.ContextMessage);
            }

            try
            {
                Guid locID         = Guid.ParseExact(loc, "N");
                var  place         = CfCacheIndex.Get(locID);
                var  startDateTime = DateTime.ParseExact(start, "dddMMMddyyyyhhmmtt", CultureInfo.InvariantCulture);
                var  endDateTime   = default(DateTime);
                if (end != "default")
                {
                    endDateTime = DateTime.ParseExact(end, "dddMMMddyyyyhhmmtt", CultureInfo.InvariantCulture);
                }

                var pc = pcSvc.CreatePartnerCall(new PartnerCall()
                {
                    Comment        = comment, StartDateTime = startDateTime,
                    EndDateTime    = endDateTime, ForIndoor = true, ForOutdoor = true, PlaceID = place.ID,
                    PreferredLevel = byte.Parse(preferredLevel)
                }
                                                 );

                var user = CfPerfCache.GetClimber(CfIdentity.UserID);

                var dto = new PartnerCallDto(place, pc, user);

                if (!pcSvc.UserHasSubscriptionForRelatedGeo(place.ID))
                {
                    pcSvc.CreatePartnerCallSubscription(new PartnerCallSubscription()
                    {
                        ForIndoor      = pc.ForIndoor,
                        ForOutdoor     = pc.ForOutdoor,
                        PlaceID        = pc.PlaceID,
                        EmailRealTime  = true,
                        MobileRealTime = false,
                        ExactMatchOnly = false
                    });
                }

                return(ReturnAsJson(dto));
            }
            catch (Exception ex)
            {
                return(Failed("PartnerCall failed : " + ex.Message));
            }
        }