Пример #1
0
        public async Task <TorrentDTO> AddTorrent(TorrentDTO torrent)
        {
            Torrent newTorrent = _mapper.Map <Torrent>(torrent);
            await _torrentRepository.AddTorrent(newTorrent);

            return(torrent);
        }
Пример #2
0
 public async Task <ActionResult <TorrentDTO> > AddTorrent(TorrentDTO torrent)
 {
     try
     {
         return(new OkObjectResult(await _movieService.AddTorrent(torrent)));
     }
     catch
     {
         return(new StatusCodeResult(500));
     }
 }
        public async Task Add_Torrent()
        {
            var torrent = new TorrentDTO()
            {
                TorrentId   = Guid.NewGuid(),
                IMDBMovieId = "tt2872732",
                MagnetLink  = "http://yts.ge/torrent/download/Her%20(2013)%20%5b1080p%5d%20%5bBluRay%5d%20%5bYTS.MX%5d.torrent",
                Quality     = "1080p",
                Seeds       = 85,
                Peers       = 357,
                FileSize    = "1.8Gb"
            };

            string json     = JsonConvert.SerializeObject(torrent);
            var    response = await Client.PostAsync("/api/torrents", new StringContent(json, Encoding.UTF8, "application/json"));

            response.StatusCode.Should().Be(HttpStatusCode.OK);

            var createdTorrent = JsonConvert.DeserializeObject <TorrentDTO>(await response.Content.ReadAsStringAsync());

            Assert.NotNull(createdTorrent);
        }