public bool Post(ShareVideoRequest request) { var userRepo = new UserRepositoryDocumentDB(); //Load user var usr = userRepo.GetUserById((Guid)HttpContext.Current.Items["UserId"]); var exercise = usr.CourseAdmissions.SelectMany(ca => ca.Results).Single(r => r.ExerciseId == request.ExerciseId) as VideoExerciseScoreCard; if (exercise.Phase != 2) { throw new Exception("Unexpected phase"); } var redirrectUrl = ConfigurationManager.AppSettings["videoReviewRedirrectUrl"]; var apiKey = "live_d54b425a127f44b8e0f60904867d9b57aeaa9775"; var emailSender = new EmailSenderSendWithUs(apiKey); var data = new { Username = usr.FirstName + " " + usr.LastName, Userimageurl = usr.ImageUrl, VideoUrl = redirrectUrl + "/#/videoreview?uuid=" + request.Uuid + "&userid=" + usr.Id, MessageToReviewer = exercise.MesageToReviewer }; emailSender.SendEmail(exercise.ReviewerEmail, data); exercise.Phase = 3; exercise.VideoUuid = request.Uuid; userRepo.SaveUser(usr); return(true); }
/// <summary> /// 分享视频 /// </summary> /// <param name="aid">视频aid</param> public void ShareVideo(VideoInfoDto videoInfo) { var request = new ShareVideoRequest(long.Parse(videoInfo.Aid), _biliBiliCookie.BiliJct); BiliApiResponse apiResponse = _videoApi.ShareVideo(request) .GetAwaiter().GetResult(); if (apiResponse.Code == 0) { _expDic.TryGetValue("每日观看视频", out int exp); _logger.LogInformation("视频分享成功,经验+{exp} √", exp); } else { _logger.LogError("视频分享失败,原因: {msg}", apiResponse.Message); } }