예제 #1
0
        private Profile CreateProfile(ProfileEnvelope env)
        {
            if (env != null)
            {
                return(new Profile(env.Id, env.UserId, env.ChartId, env.Name, env.Track, env.HighestPoint, env.LowestPoint,
                                   env.Ascending, env.Descending, env.Climbs, env.Places, env.Legs, env.Result));
            }

            return(null);
        }
예제 #2
0
        public void Handle(ProfileCreated evt)
        {
            Log.Verbose("Start handling event '{@evt}' in '{view}'", evt, this);

            var envelope = new ProfileEnvelope
            {
                Id           = evt.Id,
                UserId       = evt.UserId,
                Name         = evt.Name,
                ChartId      = evt.ChartId,
                Distance     = evt.Track.Length,
                Ascending    = evt.Ascending,
                Descending   = evt.Descending,
                StartTime    = evt.Result?.StartTime ?? evt.CreatedTime,
                TimeSeconds  = evt.Result?.TotalTimeSeconds ?? 0,
                NrOfViews    = 0,
                Kudos        = 0,
                Track        = evt.Track,
                HighestPoint = evt.HighestPoint,
                LowestPoint  = evt.LowestPoint,
                Climbs       = evt.Climbs,
                Places       = evt.Places,
                Legs         = evt.Legs,
                Result       = evt.Result,
                CreatedTime  = evt.CreatedTime
            };

            try
            {
                Log.Debug("Insert profile {@profile} started", envelope);
                _db.Insert(envelope);
            }
            catch (Exception e)
            {
                Log.Error(e, "Insert profile {@profile} failed {sql}", envelope, _db.GetLastSql());
            }
        }