Exemplo n.º 1
0
        public IActionResult UpdateEpisodeStatus(string id, [FromBody] AddToHistory model)
        {
            if (!VerifyThatShowIsEpisode(id, out var episodeInfo, out var result))
            {
                return(result);
            }

            _watchlistService.SetStatus(CurrentUserId, episodeInfo, model.WatchStatus);

            return(Ok());
        }
Exemplo n.º 2
0
        public async Task <IActionResult> UpdateShowStatus(string id, [FromBody] AddToHistory model)
        {
            var show = await _omdbApi.GetById(id);

            if (show.Type == ShowType.Episode)
            {
                return(UpdateEpisodeStatus(id, model));
            }

            _watchlistService.SetStatus(CurrentUserId, id, model.WatchStatus);

            return(Ok(_watchlistService.GetStatusForShow(CurrentUserId, id)));
        }
Exemplo n.º 3
0
        public IActionResult AddEpisodeToWatching(string id, [FromBody] AddToHistory model)
        {
            if (!VerifyThatShowIsEpisode(id, out var episodeInfo, out var result))
            {
                return(result);
            }

            var existingStatus = _watchlistService.GetStatusForEpisode(CurrentUserId, id);

            if (existingStatus == WatchStatus.InProgress || existingStatus == WatchStatus.Completed)
            {
                return(BadRequest("The episode is already in progress or completed."));
            }

            _watchlistService.AddToHistory(CurrentUserId, episodeInfo, model.WatchStatus);

            return(Ok());
        }
Exemplo n.º 4
0
        public async Task <IActionResult> AddToWatching(string id, [FromBody] AddToHistory model)
        {
            var show = await _omdbApi.GetById(id);

            if (show.Type == ShowType.Episode)
            {
                return(AddEpisodeToWatching(id, model));
            }

            var existingStatus = _watchlistService.GetStatusForShow(CurrentUserId, id);

            if (existingStatus == WatchStatus.InProgress || existingStatus == WatchStatus.Completed)
            {
                return(BadRequest("The show is already in progress or completed."));
            }

            _watchlistService.AddToHistory(CurrentUserId, id, model.WatchStatus);

            return(Ok(_watchlistService.GetStatusForShow(CurrentUserId, id)));
        }