コード例 #1
0
 public async Task <IActionResult> UpdateTalentVideo()
 {
     try
     {
         string    userId = _userAppContext.CurrentUserId;
         var       files  = Request.Form.Files;
         IFormFile file   = files[0];
         if (await _profileService.AddTalentVideo(file, userId))
         {
             string videoName = (await _profileService.GetTalentProfile(userId)).VideoUrl;
             return(Json(new { Success = true, videoName }));
         }
         return(Json(new { Success = false, Message = "File save failed" }));
     }
     catch (Exception e)
     {
         throw;
     }
 }
コード例 #2
0
        public async Task <IActionResult> UpdateTalentVideo()
        {
            try
            {
                var file        = Request.Form.Files[0];
                var userId      = _userAppContext.CurrentUserId;
                var userProfile = await _profileService.GetTalentProfile(userId);

                if (userProfile == null)
                {
                    return(Json(new { Success = false, data = "can not find the profile of the id." }));
                }
                else
                {
                    if (userProfile.VideoName != null)
                    {
                        bool removeOld = await _profileService.RemoveTalentVideo(userId, userProfile.VideoName);

                        //if (!removeOld)
                        //{
                        //    return Json(new { Success = false, data = "can not delete the old video." });
                        //}
                    }
                    bool addNew = await _profileService.AddTalentVideo(userId, file);

                    if (!addNew)
                    {
                        return(Json(new { Success = false, data = "can not add the new video." }));
                    }
                    return(Json(new { Success = true }));
                }
            }
            catch (Exception e)
            {
                return(Json(new { Data = "error" }));
            }
        }