Exemplo n.º 1
0
        public IActionResult Post(Series series)
        {
            var currentUser = GetCurrentUser();

            series.UserId = currentUser.Id;
            _seriesRepository.Add(series);
            return(CreatedAtAction("Get", new { id = series.Id }, series));
        }
 public void Verify_Add_Should_AddTheEntityToTheContext()
 {
     // Arrange
     Mock<IDbSet<Series>> mockSetSeries;
     var mockContext = SeriesMockingSetup.DoMockingSetupForContext(false, out mockSetSeries);
     var repository = new SeriesRepository(mockContext.Object);
     var series = new Series { Active = true, CustomKey = "SALVATORE-RAA", };
     // Act
     repository.Add(series);
     // Assert
     mockSetSeries.Verify(x => x.Add(series), Times.Once);
 }
Exemplo n.º 3
0
        public ActionResult Add(Series series)
        {
            ValidateSeries(series);

            if (ModelState.IsValid)
            {
                _seriesRepository.Add(series);
                TempData["Message"] = "Your series was successfully added!";

                return(RedirectToAction("Detail", new { id = series.Id }));
            }

            return(View(series));
        }
Exemplo n.º 4
0
        public void Verify_Add_Should_AddTheEntityToTheContext()
        {
            // Arrange
            Mock <IDbSet <Series> > mockSetSeries;
            var mockContext = SeriesMockingSetup.DoMockingSetupForContext(false, out mockSetSeries);
            var repository  = new SeriesRepository(mockContext.Object);
            var series      = new Series {
                Active = true, CustomKey = "SALVATORE-RAA",
            };

            // Act
            repository.Add(series);
            // Assert
            mockSetSeries.Verify(x => x.Add(series), Times.Once);
        }
Exemplo n.º 5
0
        public ActionResult Add(Series series)
        {
            ValidateSeries(series);

            if (ModelState.IsValid)
            {
                // TODO Add the series.
                _seriesRepository.Add(series); //call to the add mehtod to add the series to the DB

                TempData["Message"] = "Your series was successfully added!";

                return(RedirectToAction("Detail", new { id = series.Id }));
            }

            return(View(series));
        }
Exemplo n.º 6
0
        public void SendingNewSeries(IEnumerable <EpisodeDto> episodes)
        {
            foreach (var episode in episodes)
            {
                if (_seriesRepository.GetByNameRuSeries(episode.TitleSeries) == default)
                {
                    var seriesLink = episode.Link.Split("season")[0] + "seasons";

                    _seriesRepository.Add(new Series
                    {
                        IsCompleted  = false,
                        NameEn       = episode.TitleSeriesEn,
                        Link         = seriesLink,
                        NameRu       = episode.TitleSeries,
                        SeasonsCount = episode.NumberSeason
                    });
                    continue;
                }

                var chatIdQueue = MakeQueueChatId(episode.TitleSeries);

                var countRequests = 0;

                while (chatIdQueue.Count != 0)
                {
                    var chatId = chatIdQueue.Dequeue();

                    countRequests = SendNewEpisode(countRequests, episode, chatId).Result;

                    if (countRequests < 20)
                    {
                        continue;
                    }
                    Thread.Sleep(TimeSpan.FromSeconds(1));
                    countRequests = 0;
                }
            }
        }