public override void CreateOne() { MockVideoRepository.Setup(r => r.Create(It.IsAny <Video>())).Returns(MockVideo); var entity = _service.Create(MockVideoBO); Assert.NotNull(entity); }
public virtual async void TestDelete() { var builder = new WebHostBuilder() .UseEnvironment("Production") .UseStartup <TestStartup>(); TestServer testServer = new TestServer(builder); var client = new ApiClient(testServer.CreateClient()); client.SetBearerToken(JWTTestHelper.GenerateBearerToken()); ApplicationDbContext context = testServer.Host.Services.GetService(typeof(ApplicationDbContext)) as ApplicationDbContext; IVideoService service = testServer.Host.Services.GetService(typeof(IVideoService)) as IVideoService; var model = new ApiVideoServerRequestModel(); model.SetProperties("B", "B", "B"); CreateResponse <ApiVideoServerResponseModel> createdResponse = await service.Create(model); createdResponse.Success.Should().BeTrue(); ActionResponse deleteResult = await client.VideoDeleteAsync(2); deleteResult.Success.Should().BeTrue(); ApiVideoServerResponseModel verifyResponse = await service.Get(2); verifyResponse.Should().BeNull(); }
public void AddVideo() { Console.Clear(); Console.WriteLine("You have chosen option 2 : Add video."); Console.WriteLine(""); Console.WriteLine("Input Name of Video:"); var newVideoName = Console.ReadLine(); Console.WriteLine(""); Console.WriteLine("Input genre of the video:"); var newVideoGenre = Console.ReadLine(); Console.WriteLine(""); Console.WriteLine("Input duration of the video in minutes:"); var newVideoDuration = int.Parse(Console.ReadLine()); Console.WriteLine(""); Video video = new Video(); video.Name = newVideoName; video.Genre = newVideoGenre; video.Duration = newVideoDuration; Video createdVideo = _videoService.Create(video); PrintSingleVideo(createdVideo); }
public VideoViewModel Create(VideoViewModel video) { var createdVideo = _videoService.Create(Mapper.Map <Video>(video)); Commit(); return(Mapper.Map <VideoViewModel>(createdVideo)); }
public ActionResult <Video> PostVideo(Video Video) { // 1、阻塞30 // Thread.Sleep(30000); // throw new Exception("出现异常"); Console.WriteLine($"接受到视频事件消息"); videoService.Create(Video); return(CreatedAtAction("GetVideo", new { id = Video.Id }, Video)); }
public async Task <IActionResult> Create([FromForm] VideoRequest request, List <IFormFile> file) { var result = await _videoService.Create(request, file); if (result != null) { return(Ok(result)); } return(BadRequest("Create No Success")); }
public IActionResult Create([FromBody] Video model) { model.PublishDate = DateTime.Now; if (!ModelState.IsValid) { return(BadRequest(Result.Failed)); } var item = service.Create(model); return(Ok(item)); }
public IActionResult Create([FromBody] VideoCreate data) { try { var userData = jwtService.ParseData(this.User); VideoIndex result = videoService.Create(data, userData.UserId); return(Ok(result)); } catch (ServiceException e) { return(BadRequest(e.Message)); } }
public IActionResult Create(int id)///Id is parent dir Id { var settings = settingsService.GetVideoNoteSettings(User.Identity.Name); var videoId = videoService.Create(id, this.User.Identity.Name); var model = new VideoCreateWithSettings { ContentCreate = new VideoCreate() { Id = videoId, DirectoryId = id, }, Settings = settings, Mode = "create", }; return(View("CreateEdit", model)); }
public async Task <ActionResult> Create(VideoRequest videoRequest, IFormFile PosterVideo, IFormFile LinkVideo, string HiddenVideo) { List <IFormFile> listPost = new List <IFormFile>(); var user = await _userService.FindUser(User.Identity.Name); if (ModelState.IsValid) { if (PosterVideo != null && LinkVideo != null) { listPost.Add(PosterVideo); listPost.Add(LinkVideo); } if (user != null) { videoRequest.AppUserId = user.Id; videoRequest.HidenVideo = HiddenVideo.Contains("Public") ? true : false; var result = await _videoService.Create(videoRequest, listPost); if (result != null) { var notifi = new NotificationRequest(); notifi.AvartarUser = user.Avartar; notifi.Content = videoRequest.Name; notifi.PoterImg = result.PosterImg; notifi.UserId = user.Id; notifi.VideoId = result.Id; notifi.LoginExternal = user.LoginExternal; notifi.UserName = user.FirtsName + " " + user.LastName; var resultsNoti = await _notificationService.Create(notifi, user.Id); if (resultsNoti > 0) { return(Redirect("MyChannel")); } } } } return(Redirect("MyChannel")); }
public async Task <VideoDto> GetVideo(string spotifyId, string artist, string album, string song) { var video = await _videoService.Get(spotifyId); if (video != null) { return(video); } var track = await _trackService.Get(spotifyId) ?? await _trackService.Create(new CreateTrackRequest { SpotifyId = spotifyId, Album = album, Name = song, Artist = artist }); var searchListRequest = _youTubeService.Search.List("snippet"); searchListRequest.Q = $"{artist} {album} {song}"; searchListRequest.MaxResults = 1; var result = await searchListRequest.ExecuteAsync(); if (!(result.Items.FirstOrDefault() is { } searchResult)) { return(null); } return(await _videoService.Create(new CreateVideoRequest { TrackId = track.Id, YouTubeId = searchResult.Id.VideoId })); }