Example #1
0
        public Message LogClimbUpdate(string logID, string outcome, string experience, string gradeOpinion, string rating, string comment)
        {
            SvcContext ctx = InflateContext(); if (ctx.Invalid)

            {
                return(ctx.ContextMessage);
            }

            try
            {
                var lID = Guid.ParseExact(logID, "N");

                var log = visitsSvc.GetLoggedClimbById(lID);
                if (log == default(LoggedClimb))
                {
                    throw new ArgumentException("Logged climb does not exist as part of the specified check in!");
                }

                log.Comment      = comment;
                log.Experince    = byte.Parse(experience);
                log.Outcome      = byte.Parse(outcome);
                log.GradeOpinion = byte.Parse(gradeOpinion);
                log.Rating       = byte.Parse(rating);

                visitsSvc.LogClimbUpdate(log);

                var dto = new LoggedClimbDetailDto(log, "", "", "");

                return(ReturnAsJson(dto));
            }
            catch (Exception ex)
            {
                return(Failed("Log climb failed : " + ex.Message + " " + ex.Source));
            }
        }
Example #2
0
        public Message LogClimb(string epochUtc, string climbID, string outcome, string experience, string gradeOpinion, string rating, string comment)
        {
            SvcContext ctx = InflateContext(); if (ctx.Invalid)

            {
                return(ctx.ContextMessage);
            }

            try
            {
                var milliseconds = long.Parse(epochUtc);
                var loggedUtc    = new DateTime(1970, 01, 01).AddMilliseconds(milliseconds);

                var cID   = Guid.ParseExact(climbID, "N");
                var climb = geoSvc.GetClimbByID(cID);

                var loc = CfCacheIndex.Get(climb.LocationID);

                var visit = new VisitsService().GetVisitByLocationAndUtc(loc, loggedUtc);

                var log = visitsSvc.LogClimb(visit, new LoggedClimb()
                {
                    ClimbID      = climb.ID,
                    Comment      = comment,
                    Experince    = byte.Parse(experience),
                    Outcome      = byte.Parse(outcome),
                    GradeOpinion = byte.Parse(gradeOpinion),
                    Rating       = byte.Parse(rating),
                    Utc          = loggedUtc
                });

                var dto = new LoggedClimbDetailDto(log, climb.GradeLocal, climb.Avatar, "");

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