Пример #1
0
 public static void UpdateVideoStatsEntity(this USER_VideoStats entity, VideoStatsToken token)
 {
     entity.EndDate      = DateTime.Now;
     entity.EndPosition  = token.position;
     entity.TotalSeconds = token.position - entity.StartPosition;
     if (!String.IsNullOrEmpty(token.endReason))
     {
         entity.EndReason = token.endReason;
     }
 }
Пример #2
0
 public static USER_VideoStats StatsToken2UserVideoStats(this VideoStatsToken token, int userId, long bcId)
 {
     return(new USER_VideoStats
     {
         UserId = userId
         , SessionId = Guid.NewGuid()
         , BcIdentifier = bcId
         , ChapterId = token.ChapterId
         , StartDate = DateTime.Now
         , StartPosition = token.position
         , StartReason = token.startReason
     });
 }
Пример #3
0
        public JsonResult SaveVideoStats(VideoStatsToken token)
        {
            string error;
            Guid   sessionId;

            if (CurrentUserId < 0)
            {
                return(Json(new JsonResponseToken {
                    result = false, error = "Unauthorized access"
                }, JsonRequestBehavior.AllowGet));
            }

            var result = _widgetUserServices.SaveUserVideoStats(CurrentUserId, token, out sessionId, out error);

            return(Json(new JsonResponseToken
            {
                success = result
                , error = error
                , result = new { sessionId = result ? sessionId.ToString() : null, action = token.action.ToString() }
            }, JsonRequestBehavior.AllowGet));
        }